For such a long time, I have problems managing unusually long picture height or width.
If I decide their height and widow, will they look stacked?
If I decide their width, and if the height of the image is very long, then it will also be confusing the overall website.
If I fix their height, and if the width of the image is too long then it will mess up the entire website too.
I saved the local drive ratio to maintain? Suppose the user decides to upload image 1 (height) * 32 (width) when he uploads this image, then the script has to convert user uploaded image to height: 1000px (only one example )
As a result the image is 1000px (height) * 32000 (widht), the image you see is unusually large.
Now when displaying this image in the Box of 1000 PX * 1000 PX, what is the best way to display this image?
If you are trying to resize 32x1 image then it fits into 1000x1000 box , Then you should not change the size of the height 1000. Instead, you should resize the width 1000 and height 1000/32.
Some example codes can be:
defined (MAX_WIDTH, 1000); Defined (MAX_HEIGHT, 1000); If ($ cur_width / MAX_WIDTH & gt; $ cur_height / MAX_HEIGHT) {$ new_width = MAX_WIDTH; $ New_height = (int) ($ cur_height * MAX_WIDTH / $ cur_width); } And {$ new_width = (int) ($ cur_width * MAX_HEIGHT / $ cur_height); $ New_height = MAX_HEIGHT; }
Checks which dimensions are "big" relative to the dimensions of the box and $ new_width and $ new_height sets appropriately, make sure to handle strange cases where the dimensions One of the below goes down 0 (i.e. a 10000x1 image will probably end up as 1000x0).
Comments
Post a Comment