Member
Member
Megan   07-05-2009, 20:14
#1

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.

Member
Member
sbillard   07-05-2009, 21:27
#2

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.

Member
Member
Megan   08-05-2009, 14:45
#3

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.

Administrator
Administrator
acrylian   08-05-2009, 14:52
#4

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``

Member
Member
Megan   08-05-2009, 15:04
#5

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.

Member
Member
sbillard   08-05-2009, 15:48
#6

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.)

Member
Member
Megan   08-05-2009, 16:27
#7

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...

Member
Member
Megan   08-05-2009, 20:17
#8

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!

Member
Member
sbillard   08-05-2009, 23:44
#9

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();

Member
Member
Megan   11-05-2009, 15:41
#10

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!)

Member
Member
sbillard   11-05-2009, 16:08
#11

Did you use the code above? The error you are getting indicates that the $thumb variable was not setup. I don't really see how that could happen, though.

Member
Member
Megan   11-05-2009, 16:14
#12

It's getting a url for the $thumb, it's the getHeight/getWidth that doesn't work. This is what I have right now just for testing:

`

`

Member
Member
sbillard   11-05-2009, 16:28
#13

Ok, sorry, my fault. I gave you the wrong function to use. Change getAlbumThumb() to $_zp_current_album->getAlbumThumbImage() Of course, the echo ''.$thumb.' '; will also need to change since $thumb is an image object. echo ''.$thumb->getThumb('album').' '

Member
Member
Megan   11-05-2009, 18:46
#14

That's much better!

Now for one more small problem:

When I render the tumbnails using printCustomAlbumThumbImage it's setting the height and width attributes of the `` to the value of cropx and cropy. In template_functions.php it looks like it's is choosing whichever is higher, width or cropx, and then setting the width="" attribute to that (???). Since cropx is relative to the [i]original[/i] image it's going to be bigger than the thumb size. So I get thumbnails that are resized using the height/width attributes to something like 1450 x 1450 (or whatever the size of the original image was).

I can fix this by changing max to min or just removing the $settings variable from the ``. It is generating the thumbnails correctly.

Here's my current function:

`

`

Member
Member
sbillard   11-05-2009, 19:26
#15

I'll have to look into how to deal with this issue. The sizing is really only needed if there is no album thumb image. In the mean time, just set $sizing to "".

Member
Member
sbillard   11-05-2009, 20:05
#16

Ok, I've made some changes to the development stream to deal with this. Install tonight's nightly for the correction.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.