jamiet757 Posted January 29, 2010 Share Posted January 29, 2010 I am trying to figure out a way to make an image display as a square, for example 80x80 pixels, when the source file is rectangular. The catch is that I want the image to look normal (not squished) so the image has to be "cropped" or something, for lack of a better term. However, it should not modify the original file, just change the way it is displayed. It would be great if I could easily tie it into a <img> tag, so I can change the way it displays exactly where I want it to, and not where I don't. I haven't been able to figure this out, any help is appreciated! Link to comment https://forums.phpfreaks.com/topic/190198-display-thumbnails-as-square-while-retaining-aspect-ratio/ Share on other sites More sharing options...
premiso Posted January 29, 2010 Share Posted January 29, 2010 Cropping is exactly what you want, you can do this just with a php script that takes in the file then loads that into memory and then manipulates the memory of it, leaving the original intact. You should be able to find a tutorial about how to do this using google: http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q=php+crop+image Link to comment https://forums.phpfreaks.com/topic/190198-display-thumbnails-as-square-while-retaining-aspect-ratio/#findComment-1003466 Share on other sites More sharing options...
jamiet757 Posted January 29, 2010 Author Share Posted January 29, 2010 I tried following the example on the first result in that search, but I cannot get it to work. I had another topic asking what went wrong, but only one person answered, and he couldn't figure it out. If you can show me a working version of that, it would help. My knowledge of PHP is limited, I can get around a bit and modify a few things, but understanding what it all means is beyond me. Actually, I looked at all the results on the first and second pages, and only the first was what I actually wanted, the rest just crop the image using a specified size from the middle. I want to scale the image down, yet make it fit in a 80x80 square without being squished. Link to comment https://forums.phpfreaks.com/topic/190198-display-thumbnails-as-square-while-retaining-aspect-ratio/#findComment-1003474 Share on other sites More sharing options...
jamiet757 Posted January 30, 2010 Author Share Posted January 30, 2010 Can someone please help me out with this? I have read all the results Google gets me, and I can't make it work. Link to comment https://forums.phpfreaks.com/topic/190198-display-thumbnails-as-square-while-retaining-aspect-ratio/#findComment-1004419 Share on other sites More sharing options...
calmchess Posted January 30, 2010 Share Posted January 30, 2010 i have a resize script that I think will do just what you want.....want to download it off my server or email it to you? Link to comment https://forums.phpfreaks.com/topic/190198-display-thumbnails-as-square-while-retaining-aspect-ratio/#findComment-1004423 Share on other sites More sharing options...
jl5501 Posted January 31, 2010 Share Posted January 31, 2010 Investigate phpthumb http://phpthumb.sourceforge.net/demo/demo/phpThumb.demo.demo.php Link to comment https://forums.phpfreaks.com/topic/190198-display-thumbnails-as-square-while-retaining-aspect-ratio/#findComment-1004439 Share on other sites More sharing options...
jl5501 Posted January 31, 2010 Share Posted January 31, 2010 More specifically, what I do, using php thumb when I need to do this, is one of 2 things, both with phpthumb. Either, I do use the crop flag to crop it to the fixed square size (which sometimes crops it so as to lose bits you want to keep) or I find the dimensions of the image and set it in a square container but maintain aspect ratio by setting the largest dimension, height or width, to the size of the box, and then setting the other dimension proportionally, with a background in the box, that makes it look nice, and of course, have it centered. Link to comment https://forums.phpfreaks.com/topic/190198-display-thumbnails-as-square-while-retaining-aspect-ratio/#findComment-1004443 Share on other sites More sharing options...
jamiet757 Posted January 31, 2010 Author Share Posted January 31, 2010 Unfortunately calm, that script wasn't really what I was looking for, but phpthumb seems interesting, I will investigate it further... Link to comment https://forums.phpfreaks.com/topic/190198-display-thumbnails-as-square-while-retaining-aspect-ratio/#findComment-1004521 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.