Jump to content

Recommended Posts

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!

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

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.