I posted a thread about having zenphoto generate multiple and varying image sizes, and I can see that this only used the width value. Is there a way to have a height value specified also, so that the new generated size is cropped as well?
Thanks for you help.
Comments
I might just do that before the next version, so hold your horses ;-)
I don't mean to be rude, I am just being direct. I need to have this functionality for a project and I would like to know if I should 'try' and do it myself, have someone else do it, or hold my horses a little longer.
Thanks for your time.
Alright, I think I can do it right now. Not going to release though. I'll post a link to the latest in SVN once I'm done.
Do you need the capability to specify the position of the crop? Eg: resize image to 800x600, then take a 400x400 crop from (x,y) position (150, 100) ?
If not, I'll assume center.
If you come back...
--
There is no question that I will be back. I love this application and will continue using it for a long time yet. I just need/ed this done and was going to go elsewhere to have this feature implemented. Nothing at the moment could drag me away from this app.
Back to the question. It would be nice to be able to specify the crop region, if that is possible.
Can you tell me when it is avaible in SVN if you do it.
I hope you did not take it the wrong way. I really appreciate the work you do on this and am very thankfull to have such a wonderfull application at my displosal.
Thanks again.
EDIT: I saw that you would post a link when you were done. Sorry. I did not read that part.
It's very easy to allow specification of the crop region, so I'll add that.
Seriously, I'm not taking it the wrong way
http://svn.berlios.de/svnroot/repos/zenphoto/trunk/
The files you need to update are:
- i.php
- config.php.example (just for line 58)
- functions.php
There may be problems because of other changes, in which case you should just grab the whole thing. It's pretty stable at the moment.
Right now, the options are only available to the URL, not through mod_rewrite fancy paths, but here's an example of the parameters:
i.php?a=albumname&i=image.jpg&s=640
&cw=400&ch=300&cx=200&cy=100
s = size (of the longest side of the image if `conf['image_use_longest_side']` is true, otherwise it's the exact width. Sorry, I'll try to add specific height later)
cw = crop width
ch = crop height
cx = crop offset x (from top-left)
cy = crop offset y
So, it won't work with mod_rewrite? I don't mind. Not yet anyway.
I will give it a go and see how it handles. Thanks so much for this.
Oh, I am using the latest SVN from trunk by the way, so I updated ALL the files.
My problem:
- I wish for zenphoto to generate 3 different sized images AS WELL as the thumbnail and scaled/ cropped version in the preview.
- I input an insanely large format image into zenphoto. It generatd both preview and thumb correctly.
- Using the above code, how do now generate the following image sizes?:
- 1024x768
- 1600x1200
- 1680x1050
An example of how to generate one of these images would be appreciated, if they are all the same.Again, thanks for this.
EDIT: The original photo/image zenphoto has is actually the largest sized image (1680x1050) in this case. Thought you might need to know.
You can make any size less than 1680x1050 though.
`i.php?a=albumname&i=image.jpg&s=1228
&cw=1024&ch=768`
I had to calculate that 1228 width by hand... so I see why you need to be able to specify height. Otherwise it's just a matter of making it wide enough so it's high enough to get the crop you want. The final image size is going to be cropped from this aspect ratio original, so use cw and ch to specify the crop. You can also fine-tune the position with cx and cy.
Bottom line though, if you want it to resize up to 1600x1200, I won't put that in the official release. You have to remove a few lines in i.php... just comment out the if statement after this comment:
`// If the requested image is the same size or smaller than the original, redirect to it.` and that'll let you make images bigger than the original. Be warned though, you're losing quality...
I'll add the ability to specify height or width directly soon, until then calculate the s value needed from trial and error or the aspect ratio.
Edit: It's also important to see that you don't need to generate image files beforehand at all. The image doesn't have to be generated to be viewed, and it's all done on the fly, so using this i.php?... stuff is exactly the same as using a real image's URL. You can just throw around that URL like an image; put it in <img src="" /> tags and everything.
So I hope you're not confusing the image generation with other programs' methods... it's a lot slicker than that.
I could always give zenphoto a larger image if necessary. All the images are illustrator vector files, so they can be any size really.
I'll comment out the line and see what happens, but I think I might hold off for the specific height. I don't really want to loose quality.
Oh, and I know that all those images are generated on the fly. It is a wonderful system and now I don't (well, there are still a few issues to sort out first) all the different file sizes on the server. It can make them for me.
trisweb, is it difficult to have zenphoto generate images based on a width AND a height? I mean, is it a lot of work, or something that can be implemented in a night or so.
The problem is a matter of cropping or resizing out-of-proportion... so you're saying you'd like to resize it and crop it down? Or just specify a width and height and resize to that, losing the aspect ratio (distorting the image)? I think I'll make both available anyway, but I'd like to know what you're trying to do...
You can see what I mean with the image sizes that I need to generate. I posted those a few comments ago.
Thanks for keeping me informed of your progress and for keeping an interest in this discussion.
Use the new template functions... look for them in the php file, or in the updated stopdesign theme, which is now checked into SVN (shh ;-). Also look at the comment at the top of i.php for full documentation on the URI parameters.
What you'll want is to use either ?h=768 or ?w=xxx and then crop the other dimension. In your case, fixing the height is the way to go. So like, `i.php?a=album&i=image.jpg&h=768&cw=1024` will get you a 1024x768 image with the sides cropped off. You can then play with &cx=n to adjust the crop position if you can work out a way to do it for each image... (that's something I'm working on ;-)
And this is fun stuff. Probably my favorite part of this project. It allows for a lot of power and opportunity to streamline, so it's fun to program. :-) Thanks for using it.
I can't see why it wouldn't.
Thanks again.
- i.php
- config.php (well, its new name)
- functions.php
I can't see why that would not work.
And no, you can't just bring in the new files; they're dependent on some of those config changes. They're good changes, so it's worth it, trust me.
I do however have 1 more request (please don't hate me :-P ).
I would like to do all of this dynamically, and I was wondering if there are any, or if you can add some functions to at least get the following.
- album name (i.e. desktops)
- image name (i.e. image.jpg)
I was using (before all the cropping came into it all) the `getSizedImageURL` function, but this only supports the `s` value.
As I am generating all the images on the fly for every desktop picture I have, I can't (and don't want to) hard-code the image links into the template.
Can I make a final request, where I can have a function that allows me to parse all the values, or, a few little functions that will allow me to procude a link like the following:
`i.php?a=<?=getAlbumName;?>&i=<?=getImageName;?>h=768&cw=1024`
I am generating the same sized images all the time, so I would place that link, or something like it in the/a template file. That way, with every image, I have the selection/links to download the other x (in my case 3) image sizes.
I hope that made sense. And I am sorry to do this to you once again.
Sorry for the double post (again). I only just got it.
Your getCustomImageURL would look something like...
`getCustomImageURL(null, null, 768, 1024)`
The first two are $size and $width, which you don't want, so keep them null. This would go in the image loop, and would produce links to those sized images for each image in the album.
Hope this helps! I really should put up some better documentation so this stuff makes more sense...
All working now.