Question:
How would I use php to dynamically resize an image to fit within a set area?
Michael
2015-11-27 11:56:26 UTC
How would I use php to dynamically resize an image to fit within a set area

Also to then fill the space at either the top/bottom or left/right (depending on the orientation of the image if width or height is longer) with a solid color.

Eg I have a lot of images that are anywhere from 800-1500 pixels along he longest length and I need to proportionally resize them to fit within a space that is 200 x 200 square and portrait images will have color to the left and right to fill in the gap and landscape images will have the color top and bottom to fill the gap, this will make the image itself always be 200 x 200 pixels.

This will be used within a php script that will dynamically generate a table of images 3 columns wide by 6 rows high, which will be then copied to use within an email
Three answers:
Ray
2015-11-27 12:10:01 UTC
http://stackoverflow.com/questions/18363969/dynamically-resize-large-image-to-thumbnail-in-php
Michael
2015-11-27 13:02:13 UTC
People responding please read the entire description as so far the answers are not what I am looking for just generic answers that don't fully explain how to create what I asked.
Chris
2015-11-27 12:52:42 UTC
You can use PHP to do this but for the record, you can do this with CSS only.



http://jsfiddle.net/khrismuc/gjxn25s0/


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...