I remember reading a post about this somewhere, but I can't find it.

I'm currently trying to put ZP images in other pages. It's possible to call images directly by using code like this:
`
http://www.stanats.com/gal01/zp-core/i.php?a=pregnancy-delivery&i=03.jpg&ch=250&s=350`It will call create and cache this image:
/cache/pregnancy-delivery/03.jpg_350_ch250.jpg
The problem, I'm finding, is that using s= (for size), ch= (for crop height), etc... seems to yield some very unpredictable results.
For example, if you have a landscape photo and you want to simply resize it such that it's width is S, then you can use s=S.
But if you add a ch=Y to that, then it suddenly decides to crop both the width AND the height. This is useful, but it seems like what you'd really want to call is s=S&ch=y&cw=x. Even stranger, the amount of size reduction that happens is very hard to figure out; it's NOT zero and it's NOT the same reduction that happens when you just call s=S.
To compare, you can look at the following:
`
http://www.stanats.com/gal01/zp-core/i.php?a=pregnancy-delivery&i=03.jpg``
http://www.stanats.com/gal01/zp-core/i.php?a=pregnancy-delivery&i=03.jpg&s=350``
http://www.stanats.com/gal01/zp-core/i.php?a=pregnancy-delivery&i=03.jpg&ch=250&s=350`Is there some standard way of doing this that is better? I'd like to be able to do the following:
-size the images down
-crop the images in both axes
-slide the crop left/right and/or up/down (this part seems to work predictably so far)
Comments
http://www.stanats.com/testingsite/testingZP.htm
comments?
If you want uncropped images just use the size option. This will always process the longest side (or shortest as there is a new option in the nightly). You can't set w or h alone for uncropped image.
If you want a uncropped image fitting within width x height where height != width (for example 200x100) you need to use the new maxspace functions (and the nightly as they do not work properly in 1.2.2).
I hope that helps.
first off, in every example where I'm cropping, I am using cw AND ch. are you seeing examples where i'm not?
and the cx and cy are optional, right?
using the size option is okay, but there is no easy way to write the code to go around it since you don't know what the other dimension will be, so this is one reason why I like to crop the photos.
maybe the first step is for you to tell me if you think anything strange is happening on the page i've used as an example. to me, it seems like a lot of strange things are happening, both in terms of the sizing of the images and the cropping.
specifically:
why does h=100 cw=100 ch=80 stretch the image?
-shouldn't it simply set the height to 100, then crop it to 100 wide and 80 height?
same with h=100 cw=100 ch=40
why does w=100 cw=100 ch=80 crop the image width?
-shouldn't it resize the image so that width=100, then simply crop height to 80?
and i really don't under w=100 cw=80 ch=50
-that one seems to be cropping the image FIRST, and THEN resizing it. weird.
i have been using the maxspace functions from the nightly build, which are working well, when i am inside the ZenPhoto environment, but 1) i didn't think i could call them from outside the environment the way i'm calling these, and 2) i need to use cropped images.
sorry if i'm being dense here or frustrating you; i'm hoping to either 1) understand better how these functions work, or 2) point out an error so somebody can fix it.
if there's someone else I can talk to about it, I would be glad to do so.
thanks.
If you want to crop an image you need only to set cw and ch and optionally or only size for uncropped images. The processor should scale the image to the longest side and then crop from that.
This is how it is done for normal thumbs and the sized images on the theme functions.
Take a look at the nightly version (if you haven't you should try that anyway) of the image_album_statistics plugin's printImageStatistc() around line 396-399 and at the comment of the function to see which values it uses for cropping.
I hope that helps a little more. Besides me there is currently actually only sbillard to ask.
so I *think* you're telling me that if i want to crop AND resize images i should send something like
`http://www.stanats.com/gal01/zp-core/i.php?a=pregnancy-delivery&i=03.jpg&w=A&h=B&cw=A&ch=B`
where A and B are obviously numbers. (Obviously, this link won't work without real numbers.)
is that what you were suggesting?
if so, this does seem to work. it doesn't let you determine the sizing (magnification) of the image, but at least it doesn't stretch anything strangely. e.g., it doesn't let you print a particular 100x100 portion of the image, but that's probably okay.
For example, sometimes it's nice to have the zoomed in version that happens when you call it this way:
`http://www.stanats.com/gal01/zp-core/i.php?a=pregnancy-delivery&i=03.jpg&w=350&h=255&cw=350&ch=255`
But it is also important, in my current project, to simply be able to use this size:
`http://www.stanats.com/gal01/zp-core/i.php?a=pregnancy-delivery&i=03.jpg&w=350`
and ideally crop it.
The problems seem to be:
1. If I just use the second call, I don't know how tall it will be, so I can't insert it into a page with a specific height. Do you know if there is any way to obtain the height?
2. Cropping it at this size doesn't seem possible. Am I missing something?
So what I CAN do is simply set the width, then SEE how tall it is and insert the height into the code. But that's a very arduous solution.
The MaxSpace functions would at least offer some decent alternatives, but I don't know how to call those from outside ZP the way I'm calling these functions.
Alternativly you could try to create a image object, a $_zp_current_image variable manually by using http://www.zenphoto.org/documentation/functions/_functions.php.html#functionnewImage
all the time i've spent trying to program a solution unfortunately dwarfs the time required to do the brute force method of simply rendering a second copy of the image (sized and cropped how i want it) to be used in the blog.
i'm bummed, 'cause it would be really great if ZP could do stuff like this since it would make it play very nicely with other systems, but oh well.
thanks for your efforts in trying to get this to work.
As such, I've had good success accessing the photos via URL's like the ones I've posted above, so I don't think that's the problem.
Even in ZP, however, I don't know how to size a photo down and then crop it. Seems strange, but I don't think there's a function for that. I.e., it doesn't work to set size=something and then crop. Size is not maintained.
On a separate note, it would certainly help if I could access the ZP functions from the WordPress environment. Is there a way, from the same server, to do this? If so, how do I go about doing that. Ideally, it doesn't slow down WordPress too much; I've already noticed that my ZP stuff crawls compared to WordPress.
http://www.zenphoto.org/2008/01/hacks/#zenphoto-as-plugin
what text would i add on the end to crop this size image (without changing its magnification)?
`http://www.stanats.com/gal01/zp-core/i.php?a=pregnancy-delivery&i=03.jpg&w=350`
it seems like it should be possible (and you guys keep telling me that it is), but the things i've tried so far don't work. for example, it doesn't work to simply add cx and cy parameters after it; the results are unexpected (see the page i posted earlier).
the following works, but changes the magnification:
`http://www.stanats.com/gal01/zp-core/i.php?a=pregnancy-delivery&i=03.jpg&w=350&h=255&cw=350&ch=255`
to acrylian: thanks! that page is helpful. i'll see if i can get that stuff working. it should allow me to access width and height of the full-size pic, for example.
here's the original image, sized down:
`http://www.stanats.com/gal01/zp-core/i.php?a=pregnancy-delivery&i=03.jpg&w=300&h=199`
here's acrylian's suggestion. magnification increases:
`http://www.stanats.com/gal01/zp-core/i.php?a=pregnancy-delivery&i=03.jpg&w=300&h=199&cw=300&ch=199`
here's your suggestion (looks like its using the full-size image instead of scaling it down):
`http://www.stanats.com/gal01/zp-core/i.php?a=pregnancy-delivery&i=03.jpg&w=300&h=199&cw=250&ch=150&cx=50&cy=49`
interestingly, if i take cx and cy away, it SHOULD be the same image without shifting, but it's not:
`http://www.stanats.com/gal01/zp-core/i.php?a=pregnancy-delivery&i=03.jpg&w=300&h=199&cw=250&ch=150`
if i'm doing this incorrectly, can you simply write the correct string so i have an example?
if i'm doing what you suggested, however, then i'm still at a loss as to how to size down an image and then crop it.
sorry if i'm nagging you guys; it just seems like this should be relatively easy to do, but maybe it's not.