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)
bumpity bump? anybody?
well... i've continued experimenting and i've concluded that either i really just don't get it or it's broken. i've made a page that clearly illustrates some of the problems that i've encountered.
http://www.stanats.com/testingsite/testingZP.htm
comments?
sorry to bump this again, but i'm just totally stuck here, so any help/advice would be awesome! thanks!
As I told for cropping you need to set both the cw and ch and additional the cx and cy.
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.
okay, i appreciate your help. but i remain confused.
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.
The problem is that you set height/width and cropping ch/cw. That is not supposed to work, the image processor is just not setup for that.
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.
sorry for delay responding, been out of town. ok, so i had a look at that code and for the cropped images it's simply setting width AND crop_width to $width and height AND crop_height to $height.
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.
Yes, this does indeed work, but not without some problems.
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:
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?
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.
I am not sure if I know how to do that. I suggest you use the custom crop feature on the admin and then look at the cached images created what values they have attached.
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
yea... i think i'm going to give up. what i'm trying to do seems like it should be very simple; i'm trying to select certain images and have them appear in the blog counterpart for a specific gallery. so i need to be able to call a specific image, resize it (make it a lot smaller, kind of like a thumb), and then crop it.
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.
Okay - thanks! I'll wait to hear from you before building something else from scratch. I think I'd probably do it by grabbing a sized image from ZP, placing it in a specific sized div with overflow:hidden, then moving the image up and left to create cropping. Or something like that.
I am assuming you are accessing these images from a different server or something so that the normal hacks for using zenphoto as a plugin are not applicable. If that is the case, you will have to create manually the URIs that the zenphoto functions would have done for you. No real way around that. If you can't get the zenphoto envrionment activated on the site where you want to create the URIs there is nothing zenphoto can do for you.
Actually, it is the same server, but not in the ZP environment. I'm calling them from WordPress, but I don't find the ZenPhotoPress plug-in to be acceptable so I'm making my own functions.
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.
This method is generally used to access zenphoto function with another system:
http://www.zenphoto.org/2008/01/hacks/#zenphoto-as-plugin
to sbillard: yes, i've seen that stuff in i.php, but as i've been discussing with acrylian, it does not seem to work as expected. again, perhaps i am missing something, but as i posted earlier...
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.