Update: Due to lack of time and interest (on my part), I am no longer maintaining JSSpamBlock or ImageScaler.
WordPress has a cool WYSIWIG editor that lets you easily resize images by dragging the corner around. The problem is that WordPress does not actually resize the image, it just tells the browser to display it smaller. This means that the full sized image is being sent to the browser, which makes the page load slower and take up more bandwidth. Additionally, most browsers are bad at resizing images, so the images look worse than if they were properly resized.
To get around this, I wrote a WordPress plugin called ImageScaler. I am still waiting for it to be approved by WordPress for hosting, so I have hosted it myself for now. It requires GD (almost all web hosts with PHP will have GD). It should work with PHP 4, but it has only been tested on PHP 5.
[Example removed]
Update: the plugin is now hosted by WordPress.


WOW.
What is GD? I remember I was testing out an image resizer script in PHP, and it was copied-pasted from the website, and PHP.net also listed it as a proper function, but the image resize function gave me errors saying undefined function.. does it have anything to do with it???
GD is PHP’s image library. It is one of the PHP functions that only works if the extension is enabled. If you use a webhost that has PHP, they most likely have it already enabled. If you installed PHP yourself, you might need to enable it in the PHP configuration file (for me, /etc/php5/php.ini IIRC) or compile it into PHP. The easiest way to see if your server has GD is to create a file with <?php php_info(); ?> in it and search the page for “gd”.
Really cool idea, although I prefer to crop and scale images in Photoshop or GIMP. Then again I prefer not to use any WYSIWYG editors. It’s all about the level of control I guess.
Yeah, the quality you get from GD just won’t match the quality you get from the GIMP.
Sounds like a brilliant plugin here Paul. I hope WordPress agrees to host it for you!
Regards,
Gabriel
Gabriel, thanks. WordPress did finally get around to accepting the plugin for hosting, but I had forgotten to update the post.
Hey there – I’ve been sick of the way WP “resizes” images for a long time now, and I was ecstatic to read about your solution to this pressing issue.
Unfortunately, even though I enabled this plugin, it doesn’t seem to work! I’m running the latest WordPress (2.2.2), and I certainly do have GD, although I prefer Imagemagick.
I read that it only works for images in posts made after the plugin was installed, but making new posts with new images proves fruitless.
Any suggestions?
I cannot get this to work either.
I just moved and don’t have internet access for about another week, but I will look into this once I get back online.
I am also using WordPress 2.2.2 and i receive the following error: Fatal error: Call to undefined function: imagecreatefromjpeg() in /home/cricketl/public_html/wp-content/plugins/image-scaler/imagescaler.php on line 134
I am looking into the GD but have not been able to determine if we have it or not.
Does this only resize the picture if it is on the same server as the website? Will it resize pics hosted by flickr for instance?
Dan, yes, it will only re-size the images if they are on the same server. I would like to eventually combine this and my image re-hoster script into a single plugin, so that it would resize a flickr image for example, but I am so busy with other stuff that I doubt I will get around to doing this.
Hi Paul.
Thanks for this really useful plugin.
We have the same problem than Jason on WordPress 2.2.2.
Our site work with PHP4.
The plugin seems don’t execute the resize_image function. Maybe there’s a little bug in the regular expressions in filter_img().
LOVE this plugin. Been waiting for something to do this for a long time. It’s working fine on my site. Not sure what PHP version, but I host with powweb.com – using WP 2.3 RC1
Thanks Paul! -Scott
Scott, I’m glad you like it. I think the PHP problems are a result of not having GD enabled, so for anyone who couldn’t get it working, asking your host to enable GD may fix it.
No, GD is enabled. I am 100% sure of this – I use it for the rest of the website and for my other site, zeldawiki.org (currently switching to ImageMagick).
So, GD is not the root of the problem… I know that very well.
Jason, that is odd then. Maybe I used some PHP 4 functions without realizing it; are you running PHP 4? Unfortunately I don’t have the time to fix it, as I am busy with other projects. If you know PHP and you manage to fix it yourself, feel free to send me a copy of the modified file so others can have it as well.
I’m running php5 – php4 does not exist in any form on my server.
I know somebody who may be able to recode the plugin to work properly, or at least scan it for critical bugs. I’ll let you know if I can get anything fixed – I’m sorry that you don’t have the proper time to work on it yourself. No worries, of course.
I don’t think this plugin works properly when you have an alternative upload-path like /uploaded_files/ instead of the default /wp-content/uploads/. The code does read the upload-path from the options but doesn’t seem to use it when trying to scale etc.
I fixed my imagescaler-plugin by replacing my custom-upload-path in the php-file. Just replace it at 3 places et voila. Just search for the string “uploads”.
doesn’t work with wordpress 2.3
Thanks you so much for this plugin. I was getting so tired of resizing my images first with photoshop before I uploaded them. This saves me from doing that. You have done a great job!
Pretty good, but I’m afraid I couldn’t really play with resizing my own images using GD(I’m not too happy about it).anyway I’ve discovered a good resizer at http://reshade.com and I am more than satisfied with the results. Is your tool as good? I want to try it and compare it.
hi there .thanks for plugin:
Does anybody know if tis script is compatible with WordPress 2.5.1 ?
Thanks in advance for any help on this!
best regards
BUG: filter_image()
Why does max_height trump max_width? Probably need to comparescale in each direction for smallest.
if($max_width && $img_width * $scale > $max_width){
$scale = $max_width / $img_width;
}
if($max_height && $img_height * $scale > $max_height){
$scale = $max_height / $img_height;
}