When I upload an Image with Joomla the .jpg has a much bigger filesize on the server than it had when it was on my harddrive. It usually is about 2-3 times bigger, although the dimensions are the same or smaller. Of course this is not good for the performance of the website. I could imagine that some library changes the compression of the image but I don't know where to start looking.
I use Joomla 3 and PHP 5.4 on an Apache Webserver.
Thanks for your help!
Related
I use Imagine library and I would like to know if is it possible to compress images with this library?
Other question:
Do you think it's a good solution to compress a lot (30 images) of images with the library in order to use a command line?
You can save the images with lesser quality to compress them:
To save at 50% quality:
$imagine->open('/path/to/image.jpg')->save('/path/to/image.jpg', array('quality' => 50));
And as for whether or not to do the compression at command line, you can do it but I don't recommend it. Image manipulation takes a lot of cpu and ram, so I suggest you download the images and manipulate them on your computer (not on the production server), or do it in a php script but limit the number of images to compress.
I am looking for a loss-less JPEG optimization tool that I can include in a PHP-based photo gallery software.
I already checked the following question, but ruled out the tools mentioned there for reasons I'll explain below:
Tools for JPEG optimization?
The command line tools jpegtran and jpegoptim are not available in the average PHP hosting account. The web-based tools (www.smush.it, www.kraken.io) all have a limit of 1 MB for processed images.
The 1 MB limit is a problem, because the gallery software delivers images based on browser-size and I also want to support Full HD and even larger displays. Depending on content, photos prepared for such resolutions can get larger than 1 MB.
Any hints on a solution are appreciated!
OK, I found my answer in another stack overflow question:
JPG File Size Optimization - PHP, ImageMagick, & Google's Page Speed
ImageMagick already does the Huffman optimization. I assumed it doesn't because my ImageMagick files were still larger then the ones from jpegtran & Co. However, that was only because I did not strip the metadata.
Cheers, Robert
There are no solution.
Either use some command-line utility or increase memory limit.
(and, to let you know, it's not target image file size but uploaded image dimensions that puts you into trouble with memory limit.
My website is showing same image, one normal and other is blurred and I'm thinking what is better method of doing it in terms of speed. Create two images upon uploading where it uploads one normal image and one blurred to server or upload only one image but blur second one on the fly using gd?
If you're using GD, I would do it at upload and save them as flat files.
Apache and other web servers can serve flat files remarkably fast.
However, I would look into using http://www.graphicsmagick.org/ to do the image manipulation. It's much, much faster and efficient than Imagemagick and most certainly PHP's GD.
I have a resize script i made in PHP that uses GD (my VPS doesn't have imagemagick installed) to resize an image, I have recently started getting memory errors so i have increased the memory_limit up to 50Mb and still get memory error.
The image I am trying to resize is only 2Mb, is this correct for PHP image stuff, something sounds a bit wrong to me.
To resize the image GD has to work on the uncompressed image, which is significantly larger than 2MB, I assume. Imagemagick needs to store the entire image data (pixels * bit_depth) and quite some more for the actual work in memory.
50 Megabytes is not much for working with images. For example, Drupal warns you if you have less than 96MB memory limit, if you have the image resizing, etc.. enabled. For reasonably sized images 64MB are enough in my experience, but if you put full size images from a digital camera you'll run into problems with that memory limit.
On my shared/cloud hosting (2.7£/month) I still did not see any warning/error when resizing images. I set the limit to 200MB (sometimes users need to upload very large images). As Fabian said, I guess 50 is too low.
I'm wondering how to compress an PNG image correctly.
The situation is this :
I have a PNG image compressed and color-reduced with Irfanview on Windows. It's about 20KB.
When my portal software resizes (using magickwand 1.0.7) it with default values, it's about 63K (!).
Next try was to call MagickSetImageDepth($this->_imageHandler,8), resulting in a filesize of 34K, which is better, but still it's bigger than the (larger in dimension) original file.
None of the documented functions seem to fit to further compress the image.
Any hint would be greatly appreciated !
Greetz,
Sosa
PNG compression programs and routines use different techniques. I've found out that many times, an image that's already been compressed (or saved efficiently) cannot be compressed further or even has a higher file size as you are experiencing.
In your case I'd say your images cannot be compressed further, at least using MagickWand. You might just want to leave out that step.
Perhaps optimizing your PNGs before runtime would be a solution. There are many options available in this case. I've had luck with PNGGauntlet. You can run a batch job on PNGGauntlet and it will skip over the files that it would've made larger, if any.
Try this tool by Yahoo - it's great!
http://developer.yahoo.com/yslow/smushit/