Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Seems like you've already accepted an answer but I'm gonna still post mine.</p> <p>First of all, you really don't need to use <strong>100%</strong> in quality, a <strong>90%</strong> or <strong>85%</strong> value will do just fine while decreasing your processing time and image size (if you don't believe me just run some tests).</p> <p>I've also done some benchmarks with <a href="http://cambodianlivingarts.co.uk/downloads/ChildrenoftheKhmer_edinburgh1.jpg" rel="noreferrer">this image</a> and a custom <code>JPEG()</code> function, <strong>first test case:</strong></p> <pre><code>JPEG('./original.jpg', null, '1024*774', './output/large.jpg'); JPEG('./original.jpg', null, '500*378', './output/medium.jpg'); JPEG('./original.jpg', null, '240*161', './output/small.jpg'); JPEG('./original.jpg', null, '100*76', './output/thumb.jpg'); JPEG('./original.jpg', null, '50*38', './output/small_thumb.jpg'); JPEG('./original.jpg', null, '75*75', './output/square.jpg'); </code></pre> <p>This takes an average of 60 seconds on my slow <strong>slow</strong> computer.</p> <hr> <p><strong>Second test case</strong>:</p> <pre><code>JPEG('./original.jpg', null, '1024*774', './output/large.jpg'); JPEG('./output/large.jpg', null, '500*378', './output/medium.jpg'); JPEG('./output/medium.jpg', null, '240*161', './output/small.jpg'); JPEG('./output/medium.jpg', null, '100*76', './output/thumb.jpg'); JPEG('./output/medium.jpg', null, '50*38', './output/small_thumb.jpg'); JPEG('./output/medium.jpg', null, '75*75', './output/square.jpg'); </code></pre> <p>This one takes "only" 16 seconds (my computer is really slow ATM <strong>:P</strong>), almost 4 times faster.</p> <hr> <p><strong>Here is the <code>JPEG()</code> function in case you want to make your own benchmarks:</strong></p> <pre><code>function JPEG($source, $crop = null, $scale = null, $destination = null) { $source = ImageCreateFromJPEG($source); if (is_resource($source) === true) { $size = array(ImageSX($source), ImageSY($source)); if (isset($crop) === true) { $crop = array_filter(explode('/', $crop), 'is_numeric'); if (count($crop) == 2) { $crop = array($size[0] / $size[1], $crop[0] / $crop[1]); if ($crop[0] &gt; $crop[1]) { $size[0] = $size[1] * $crop[1]; } else if ($crop[0] &lt; $crop[1]) { $size[1] = $size[0] / $crop[1]; } $crop = array(ImageSX($source) - $size[0], ImageSY($source) - $size[1]); } else { $crop = array(0, 0); } } else { $crop = array(0, 0); } if (isset($scale) === true) { $scale = array_filter(explode('*', $scale), 'is_numeric'); if (count($scale) &gt;= 1) { if (empty($scale[0]) === true) { $scale[0] = $scale[1] * $size[0] / $size[1]; } else if (empty($scale[1]) === true) { $scale[1] = $scale[0] * $size[1] / $size[0]; } } else { $scale = array($size[0], $size[1]); } } else { $scale = array($size[0], $size[1]); } $result = ImageCreateTrueColor($scale[0], $scale[1]); if (is_resource($result) === true) { if (ImageCopyResampled($result, $source, 0, 0, $crop[0] / 2, $crop[1] / 2, $scale[0], $scale[1], $size[0], $size[1]) === true) { return ImageJPEG($result, $destination, 90); } } } return false; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload