Jump to content

A not so simple image manipulation


Adam Kiss
 Share

Recommended Posts

Hi all,

I would like to do resizing/triming on some pictures, but due to nature of the pictures, I need quite exact procedure:

  • Trim image to 1020px width
  • resize image to have 200px width
  • trim anything below 180px

Is it possible via image API? Or is there any way I may connect straight to ImageField and do all this with the script Image API is using?

Adam

Link to comment
Share on other sites

Adam,

The image functions just do resize and crop to center at the moment (more advanced functions coming soon). ProcessWire just uses php for these functions, not a separate script/library. But what I would suggest is to exec() to ImageMagick, which is installed on almost all unix hosting accounts, and will accomplish what you need relatively easily.

Let me know how it works out.

Thanks,

Ryan

Link to comment
Share on other sites

That actually won't work at all, unfortunately, because on at least one place, I have no exec rights.

UPDATE: How can I tell PW to crop the image, rather then resize the image? Because I figure I can crop, resize and just hide the bottom part below certain height with CSS.

Old questions:

Would be possible to create some 'EnhancedImageField' object maybe? with some advanced (little advanced) cropping functions?

Or maybe, get the old file, push it into some PHP image library and get back some object, which will be stored via processwire?

Link to comment
Share on other sites

Adam,

You can crop just by using the size() function, and setting the dimension you don't want to change. So to crop the height ,get the existing width to maintain it

$w = $page->image->width();

$image = $page->image->size($w, 200);

That would

Maintain the width but crop the height

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...