Jump to content

How to use ImageSizer


owzim
 Share

Recommended Posts

I'd like to resize some images on demand, that are not page images, so they are not attached to a page.

How to use the ImageSizer class? I could browse through the code but perhaps someone who used this, could provide some lines of example code.

I basically want to pass the image path and cropping options.

Are the cropped images saved somewhere if they are not page images, or will the cropping be executed every time?

Thanks!

  • Like 2
Link to comment
Share on other sites

Well you could create a new Pageimage from the image path:

$image = new Pageimage($page->images, "/path/to/image.jpg");

Then you could run sizer on the page image. Then delete the pageimage if you want.

I think something like that should work. Either that, or just use standard GD commands.

  • Like 1
Link to comment
Share on other sites

@owzim: best way to understand how it works is to look into Pageimage.

There you see that ImageSizer only gets a filename of an image variation and the manipulation params ($options) and that it saves the result right into that given filename. All other, (caching, renewing, etc) isn't handled by ImageSizer (but by Pageimage).

Edited by horst
  • Like 1
Link to comment
Share on other sites

I investigated both approaches and went with @horst's suggestion on my Blick module. Although I think in the long run the whole image resize caching should be decoupled from the PageImage class, so that it can be used outside of page images. I'll elaborate more on that some other day, how that could be best accomplished, since it's not that easy and a lot of refactoring would be necessary.

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...