Jump to content

Recommended Posts

On the site that I am building. I have several images, some are tall images and some are wide images, I was wondering if there was a way with PHP that I can choose what demonsions are used to display the image based on image pixels?

 

Something like

if ($image = 450px ) {
          display width = "250" height = "150"
} else {
           display width = "150" height = "250"
}

 

If there is away how would I go about doing any suggestions?

Link to comment
https://forums.phpfreaks.com/topic/235360-is-this-possible/
Share on other sites

you can use the gd() object for image manipulation to get the width and height, personally i would use a dynamic thumbnail script (that someone else wrote since theres plenty of them) to display the image to any size/proportion i chose. it would look something like <img src="thumbnailscript.php?file=picture.jpg&width=100&height=200"> passing the info to the php to spit out the image how you want it

 

or use javascript to resize it client side, but of course that relies on javascript to be turned on (who even turns it off anyway I ask myself!!)

Link to comment
https://forums.phpfreaks.com/topic/235360-is-this-possible/#findComment-1209500
Share on other sites

You seem to be confused about what pixels are used for.  Pixels are not equivalent to "area".  When you have dimensions for height and width, those dimensions are in pixels.  Your pseudo code doesn't make any sense.

 

There are several different libraries (exif, gd, imagemagick) which have routines that can be used to open most common image files and return you information including the height and width in pixels.

Link to comment
https://forums.phpfreaks.com/topic/235360-is-this-possible/#findComment-1209791
Share on other sites

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.