Resize Image After Upload - Version 1.8.3

Version Description

Release date: 20th December 2017

  • [Fix] Skip animated GIFs that GD can't resize.
Download this release

Release Info

Developer jepsonrae
Plugin Icon 128x128 Resize Image After Upload
Version 1.8.3
Comparing to
See all releases

Code changes from version 1.8.2 to 1.8.3

Files changed (2) hide show
  1. readme.txt +8 -2
  2. resize-image-after-upload.php +32 -3
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: ShortPixel
3
  Donate link: https://www.paypal.me/resizeImage
4
  Tags: image, resize, rescale, bulk resize, bulk rescale, downsize,
5
  Requires at least: 3.5
6
- Tested up to: 4.8
7
- Stable tag: 1.8.2
8
 
9
  Automatically resize your images after upload using this plugin. Specify height&width, the plugin will do the rest quickly and transparently.
10
 
@@ -43,6 +43,12 @@ Is that simple, just give it a try, it is safe and free! :-)
43
 
44
  == Changelog ==
45
 
 
 
 
 
 
 
46
  = 1.8.2 =
47
 
48
  Release date: 21th August 2017
3
  Donate link: https://www.paypal.me/resizeImage
4
  Tags: image, resize, rescale, bulk resize, bulk rescale, downsize,
5
  Requires at least: 3.5
6
+ Tested up to: 4.9
7
+ Stable tag: 1.8.3
8
 
9
  Automatically resize your images after upload using this plugin. Specify height&width, the plugin will do the rest quickly and transparently.
10
 
43
 
44
  == Changelog ==
45
 
46
+ = 1.8.3 =
47
+
48
+ Release date: 20th December 2017
49
+
50
+ * [Fix] Skip animated GIFs that GD can't resize.
51
+
52
  = 1.8.2 =
53
 
54
  Release date: 21th August 2017
resize-image-after-upload.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Resize Image After Upload
4
  Plugin URI: https://wordpress.org/plugins/resize-image-after-upload/
5
  Description: Automatically resize uploaded images to within specified maximum width and height. Also has option to force recompression of JPEGs. Configuration options found under <a href="options-general.php?page=resize-after-upload">Settings > Resize Image Upload</a>
6
  Author: ShortPixel
7
- Version: 1.8.1
8
  Author URI: https://shortpixel.com
9
 
10
  Copyright (C) 2017 ShortPixel
@@ -24,7 +24,7 @@ along with this program; if not, write to the Free Software
24
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
  */
26
 
27
- $PLUGIN_VERSION = '1.8.2';
28
  $DEBUG_LOGGER = false;
29
 
30
 
@@ -252,7 +252,7 @@ function jr_uploadresize_options(){
252
 
253
  <h4 style="font-size: 15px;font-weight: bold;margin: 2em 0 0;">Like the plugin?</h4>
254
 
255
- <p>This plugin was written for free (as in free beer) by me, <a href="http://philr.ae" target="_blank">Phil Rae</a>. If you find it useful please consider donating some small change to my beer fund because beer is very seldom free. Thanks!</p>
256
 
257
  <p style="padding-bottom:2em;" class="resizeimage-button-wrapper">
258
  <a class="resizeimage-button" href="https://www.paypal.me/resizeImage" target="_blank">Donate cash</a>
@@ -430,6 +430,12 @@ function jr_uploadresize_resize($image_data){
430
  $image_data = jr_uploadresize_convert_image( $image_data, $compression_level );
431
  }
432
 
 
 
 
 
 
 
433
  //---------- In with the old v1.6.2, new v1.7 (WP_Image_Editor) ------------
434
 
435
  if($resizing_enabled || $force_jpeg_recompression) {
@@ -566,6 +572,29 @@ function jr_uploadresize_convert_image( $params, $compression_level ){
566
  return $params;
567
  }
568
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569
  /**
570
  * Simple debug logging function. Will only output to the log file
571
  * if 'debugging' is turned on.
4
  Plugin URI: https://wordpress.org/plugins/resize-image-after-upload/
5
  Description: Automatically resize uploaded images to within specified maximum width and height. Also has option to force recompression of JPEGs. Configuration options found under <a href="options-general.php?page=resize-after-upload">Settings > Resize Image Upload</a>
6
  Author: ShortPixel
7
+ Version: 1.8.3
8
  Author URI: https://shortpixel.com
9
 
10
  Copyright (C) 2017 ShortPixel
24
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
  */
26
 
27
+ $PLUGIN_VERSION = '1.8.3';
28
  $DEBUG_LOGGER = false;
29
 
30
 
252
 
253
  <h4 style="font-size: 15px;font-weight: bold;margin: 2em 0 0;">Like the plugin?</h4>
254
 
255
+ <p>This plugin was written for free (as in free beer). If you find it useful please consider donating some small change to my beer fund because beer is very seldom free. Thanks!</p>
256
 
257
  <p style="padding-bottom:2em;" class="resizeimage-button-wrapper">
258
  <a class="resizeimage-button" href="https://www.paypal.me/resizeImage" target="_blank">Donate cash</a>
430
  $image_data = jr_uploadresize_convert_image( $image_data, $compression_level );
431
  }
432
 
433
+ if($image_data['type'] == 'image/gif' && is_ani($image_data['file'])) {
434
+ //animated gif, don't resize
435
+ jr_error_log("--animated-gif-not-resized");
436
+ return $image_data;
437
+ }
438
+
439
  //---------- In with the old v1.6.2, new v1.7 (WP_Image_Editor) ------------
440
 
441
  if($resizing_enabled || $force_jpeg_recompression) {
572
  return $params;
573
  }
574
 
575
+ function is_ani($filename) {
576
+ if(!($fh = @fopen($filename, 'rb')))
577
+ return false;
578
+ $count = 0;
579
+ //an animated gif contains multiple "frames", with each frame having a
580
+ //header made up of:
581
+ // * a static 4-byte sequence (\x00\x21\xF9\x04)
582
+ // * 4 variable bytes
583
+ // * a static 2-byte sequence (\x00\x2C) (some variants may use \x00\x21 ?)
584
+
585
+ // We read through the file til we reach the end of the file, or we've found
586
+ // at least 2 frame headers
587
+ $chunk = false;
588
+ while(!feof($fh) && $count < 2) {
589
+ //add the last 20 characters from the previous string, to make sure the searched pattern is not split.
590
+ $chunk = ($chunk ? substr($chunk, -20) : "") . fread($fh, 1024 * 100); //read 100kb at a time
591
+ $count += preg_match_all('#\x00\x21\xF9\x04.{4}\x00(\x2C|\x21)#s', $chunk, $matches);
592
+ }
593
+
594
+ fclose($fh);
595
+ return $count > 1;
596
+ }
597
+
598
  /**
599
  * Simple debug logging function. Will only output to the log file
600
  * if 'debugging' is turned on.