Thanks for this very, *very* handy API!
I try to resize/crop a given image and overwrite the file on disk with new version, but due to errors below, I'm only able to generate a resized version.
Following the example given in imageapi.module:
<?php
// to overwrite original image:
imageapi_image_close($image) ;
?>
you get the following error:
warning: Missing argument 2 for imageapi_image_close()
Problem:
second argument ($destination) is mandatory, thus forcing you to provide it which leads to generation of a resized/cropped copy of the original
Workaround:
<?php
imageapi_image_close($image, $node->field_x_image[0]["filepath"]);
?>
Downside: original image remains in folder. Resized image gets renamed to myname_1.png
Comments
Comment #1
jpoesen commentedIn retrospect: contrary to the documentation in imageapi.module, a correct example is given in README.txt, in the API Quick reference section:
However, I'm still not clear on how to overwrite a manipulated file...
thanks.
Joeri.
Comment #2
dopry commentednice catch... I'll see about cleaning this up tomorrow... What would be your expected behavior? that close just overwrites the original image? I think that might be nicest myself.
Comment #3
jpoesen commentedI agree, just using "close" is the most intuitive for overwriting.
Adding an optional $destination would allow for saving the altered image alongside the original.
Oh, and something else: it was kind of hard to figure out how to scale an image if you only want to set target width for example. Since both width and height are mandatory, this is kind of confusing. By studying either imageAPI or imagecache (I forgot which one), I saw you need to set an impossibly high value for height (in my case) to make it work.
I think using imageapi_scale($image, 200, 99999) is not really intuitive, and it's not documented. Maybe implement using 0 or -1 and document it? Would that be an acceptable solution?
thanks!
Comment #4
dopry commentedfix committed to HEAD.
Comment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.