![]() |
|
Custom cropped sizes and aspect ratios - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: General support (https://forum.zenphoto.org/forum-4.html) +--- Thread: Custom cropped sizes and aspect ratios (/thread-3322.html) |
Custom cropped sizes and aspect ratios - kace - 2008-07-18 Hi, I am needing to have images cropped on the fly based on what resolution the user needs. (it's for a wallpaper site.) Say I have an image that is 2560x1920 but I want to have a link to a widescreen version which would for example be something like 1280 x 800. I need to know what the code would be for this. For an example, I am currently using this So what I need to know is what to enter between the () that would crop the image to the dimensions I specify--essentially changing the aspect ratio of the image. Also, I need to specify the offset of the crop so that it will crop an equal amount off the top and the bottom of the image so that I'd have a nice 16:10 widescreen aspect ratio. Thanks in advance for any help you can provide. Custom cropped sizes and aspect ratios - sbillard - 2008-07-19 The function parameters can be found in the functions guide http://www.zenphoto.org/documentation/zenphoto/_template-functions.php.html. The explaination of the parameters is found at the beginning of the i.php file. Custom cropped sizes and aspect ratios - kace - 2008-07-19 Thank you. I have been to that page before and also the i.php and being that I'm new to php and pretty clueless, I have been unable to figure out the correct parameters. I've tried so many different variations and I'm just not getting it to work. (Sorry for being a retard about this.) Could you give me an example of the code I would need to resize a 2560 x 1920 image to 1280 x 800? I can't seem to get it to crop it both sides. I end up with it resized to the 1280 width but not 800 height. This is the code I figured would work, but just changes the width: `` Obviously it is not the correct code to use... what am I doing wrong? Thanks! Custom cropped sizes and aspect ratios - sbillard - 2008-07-19 When you pass parameters to a function in PHP they are passed by position. So your code above set two local variables to 1200 and 800 then passed these as the size and width parameters to A good practice if you are new to something like this is to do a search on the zenphoto files for uses of the function to have examples of how things are used. This particular function is used in the effervescence+ theme. There is also Custom cropped sizes and aspect ratios - kace - 2008-07-20 Thank you! I love learning about this. I finally got it right and this is the code that works for me: |