ZenphotoCMS Forum
Problems with custom thumbnails and crop positions - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: Themes (https://forum.zenphoto.org/forum-5.html)
+--- Thread: Problems with custom thumbnails and crop positions (/thread-5152.html)

Pages: 1 2


Problems with custom thumbnails and crop positions - Megan - 07-05-2009

Hello,

I just upgraded from Zenphoto 1.1.5 to 1.2.4. Everything seems fine except for the custom functions I was using to generate thumbnails in the old version. These are the functions I'm using:

On the index:
``

On the album pages:
` `

These work fine in 1.1.5 but in 1.2.4 the thumbnails are really weirdly distorted and stretched out. Any numbers I put in for the crop positions seem to cause the same problems.

Here's my gallery:

http://pole.uwaterloo.ca/cpadev/news/gallery/Research/

Also, a few questions about the parameters in these functions:

What exactly does "size" mean? How is this used in relation to the height and width dimensions? And the crop dimensions? I'm confused about why the numbers I used get the results I they did.

Does cropping really start at the top-left corner? Because it looks to me that it's centered on the image (e.g. I have 180px images with a 150px crop - the crop takes off about 15 pixels on either side, rather than 30px at the bottom/right). If this is the case, then where are cropx and cropy measured from?

Do these parameters override the settings in theme options?

Thanks for any help.




Problems with custom thumbnails and crop positions - sbillard - 07-05-2009

size is an altenative to height/widht. You should not have all three items set. In your case, height/width should probably be NULL since you seem to want a 180x180 image.

first the crop is done by taking a slice of the image from (cropx,cropy) to (cropx+cropw,cropy+croph) then the result is resized to fit either size or height x width. If cropx or corpy are not given then the value used is 1/2 the "trimmed" area. In other words if both are not provided, the crop is centered on the image. Zero is, unfortunately, the same as not provided due to the foibles of PHP. You would have to use 1 i you want the edge of the image.

The parameters override any settings. More to the point, there are no theme settings for the custom functions.




Problems with custom thumbnails and crop positions - Megan - 08-05-2009

Thanks a lot, that's a big help. I'm in the middle of working with this now. Currently I'm using this:

` `

Which gets me something resembling a normally scaled image, although they are being scaled on the long side instead of cropping.

The question is: why in the world did I have to go up to 15000 for the cropw and croph to get a normal section of the image???

Does the Stop Design theme work okay for others? For me it has the same problems I was having originally.




Problems with custom thumbnails and crop positions - acrylian - 08-05-2009

If you want cropped images you should not set the $size parameter. This is for uncropped images only (depending on the admin setting by longest side etc). Try something like``




Problems with custom thumbnails and crop positions - Megan - 08-05-2009

That seems to be getting me the same result I had when I was using $size...

So the thumbnails use the admin setting under image size for longest side etc.? Changing that setting doesn't seem to make a difference.




Problems with custom thumbnails and crop positions - sbillard - 08-05-2009

Stopdesign is working correctly for me. Maybe a good experiment would be to use the custom thumb cropping in admin. This will store its values in the database. You can then look at the image record in the database and see what values it used.

Cropw and croph are relative to the full sized image, so yours would have to be 15000x15000 for that to be correct. I doubt they are that large, so there must be someting else wrong.

At this point I would a clean install of the nightly build. Maybe there are some bad files in your install. (Just a guess, though.)




Problems with custom thumbnails and crop positions - Megan - 08-05-2009

Ooooooh, so it's cropping from the full sized image! That makes a bit more sense now. These functions take the original image, then crop it to the dimensions specified from the x/y axis specified, then resize to $size or height/width. That probably won't work well for me - some original images may be larger/smaller than others.

Are all the details about how these parameters work documented anywhere? That would be useful.

Is there more custom thumb cropping in admin than what's under theme options? (thumb size, crop thumbnails).

I think the stop design theme is actually working now, dont' know why it was showing the distorted thumbnails before. I notice he's using get custom sized image so maybe I'll try that ... All I'm trying to do is move the crop position up a bit so that peoples' heads don't get cut off in the thumbnails.

This worked fine for me in 1.1.5 but I think I might have messed around with the zp-core files at the time...




Problems with custom thumbnails and crop positions - Megan - 08-05-2009

Okay, found a solution. What I needed to do was find the short edge of the image, crop it in a square to that size from the origins specified, then resize. After looking at the stopdesign code, I found out how to find out if it's landscape or not, then put in different printCustomSizedImage functions for each:

`

`
Not sure why I had to write that formula to get the $cx position for the landscape images... otherwise it was resizing & squishing them.

New question: isLandscape() and getHeight()/getWidth() aren't available for album thumbs. Is there anything else I could use instead?

Thanks a million for all your help!




Problems with custom thumbnails and crop positions - sbillard - 08-05-2009

The album thumb is actually an image. $thumb = getAlbumThumb(); Of course you have to use the object methods to get information about the thumb. $landscape = $thumb->getWidth()>=$thumb->getHeight();




Problems with custom thumbnails and crop positions - Megan - 11-05-2009

Okay, when I do that I get an error "call to a member function getWidth() on a non-object". Is there something I'm missing here??

(sorry about my crappy PHP skills!)