Jump to content

resize images with different settings


thuijzer
 Share

Recommended Posts

Right now this doesn't seem to work:

$url1 = $image->size(100, 100)->url;
$url2 = $image->size(100, 100, array('upscale' => false, 'cropping' => false))->url;

This is because a filename like image.100x100.jpg is created for both settings.

Is there a workaround for this?

If not, maybe an additional MD5 hash of the settings could be added to the filename: image.100x100.d8e8fca2dc0f896fd7cb4cb0031ba249.jpg ?

  • Like 1
Link to comment
Share on other sites

While reading the code I noticed the suffix options in the Pageimage class.

It seems some settings are added as suffix but not all. So my workaround for now is:

$url1 = $image->size(100, 100)->url;
$url2 = $image->size(100, 100, array('upscale' => false, 'cropping' => false, 'suffix' => array('noupscsale', 'nocrop')))->url;

Resulting in:

  • image.100x100.jpg
  • image.100x100-noupscale-nocrop.jpg
  • Like 2
Link to comment
Share on other sites

Good find! ..., and welcome to the forums. :)

PS: do you know PIA? She can assist in images API coding.

$url2 = $image->size(100, 100, array('upscale' => false, 'cropping' => false, 'suffix' => array('noupscsale', 'nocrop')))->url;

can be written like

$url2 = $image->contain("size=100, suffix=noupscsale-nocrop")->url;
Edited by horst
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...