After performing an upscale action I need to re-reduce the quality of jpegs back down to 75%, so I'm trying to set up a custom preset... I've written the code which should work... but was having problems....

logged the $image->info['extenstions'] and found only .png's are being presented...

I urgently need to recompress the jpegs so is there any version of the module that auto recompresses or gives me access to jpegs thru the custom preset...

If anyone knows of a work around to give me a temporary fix that would be useful too!

All suggestions gratefully received

regards
Mark

Comments

MJD’s picture

OK I can add some extra info on this...

I'm trying to perform the following actions:-

1) scale-9
2) Canvas
3) Custom

In this order my custom code doesn't see the jpegs to allow me to reduce the quality (just pngs)... If I move my custom code to 1st or 2nd my code runs... but of course I don't end up with the image quality reduced...

MJD’s picture

Ok I ended up manually building the problem cache but now have a workaround for my "Custom Action";

The problem is that

<?php $image->info['mime_type'] ?> & <?php $image->info['extension'] ?>

always come thru as png (on this site there only jpegs & pngs)...

I presume it is the fault of either "Scale 9" or "Canvas"...

I have done a workaround for this... Here's my test solution (not the final one)

<?php
$jpg = false;

$jpg = ($image->info['mime_type'] == 'image/jpeg' ||  $image->info['extension'] == 'jpg' || // << don't work obviously
        strpos($image->source,'.jpeg') > 0 ||  strpos($image->source,'.jpg') > 0);

if ($jpg)
{
  imagejpeg($image->resource, "tmp/temp.jpg", 70);

  $image->resource = imagecreatefromjpeg("tmp/temp.jpg");
  $image->info['mime_type'] = 'image/jpeg'; // wont work without repair invalid mime_type
  $image->info['extension'] = 'jpg';        // wont work without repair invalid extension
}

return $image;
?>

I've now got the images down to the right size!

Hope this helps anyone who needs to reduce the jpeg size after upscaling and finding the images are as big or bigger than the originals!

fietserwin’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

D6 EOL. This module's D6 issues already haven't received any attention for over a year. Closing them all unconditionally now.