472,971 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,971 software developers and data experts.

PHP native graphics/image function

How do I find the information about an image, e.g. its dimension, whether
it's jpg, tiff, bmp, gif, etc using the
native PHP function? I know that we can do it by using the imagemagick, but
perhaps some webhosting site does not have that installed. Thanks
Jul 17 '05 #1
3 3893
Continue ...

Once we determine the type of the image, it's size, then I'd like to
resize(proportionately), then convert them to, say, a jpg file. And, then
display them. Thanks

"Ruby Tuesday" <ru*********@yahoo.com> wrote in message
news:c4*************@ID-205437.news.uni-berlin.de...
How do I find the information about an image, e.g. its dimension, whether
it's jpg, tiff, bmp, gif, etc using the
native PHP function? I know that we can do it by using the imagemagick, but perhaps some webhosting site does not have that installed. Thanks

Jul 17 '05 #2
"Ruby Tuesday" <ru*********@yahoo.com> wrote in message
news:c4*************@ID-205437.news.uni-berlin.de...
How do I find the information about an image, e.g. its dimension, whether
it's jpg, tiff, bmp, gif, etc using the
native PHP function? I know that we can do it by using the imagemagick, but perhaps some webhosting site does not have that installed. Thanks


You might start with the manual:
http://us2.php.net/manual/en/ref.image.php

Here's a script you can tinker with to get started:

<?PHP
// Capture GET parameters
$source_file = $_GET['image'];
$new_width = $_GET['width'];
$new_height = $_GET['height'];

// Open source image file and get image dimensions
$old_image = imagecreatefromjpeg($source_file);
$old_width = imagesx($old_image);
$old_height = imagesy($old_image);

// Create blank image
$new_image = imagecreatetruecolor($new_width,$new_height);

// Copy and resize old image into new image resource and then return to
browser

imagecopyresized($new_image,$old_image,0,0,0,0,$ne w_width,$new_height,$old_w
idth,$old_height);
header('Content-type: image/jpeg');
imagejpeg($new_image);
?>

Called with:
<img src="imagethumb.php?image=test.jpg&width=100&heigh t=75" ... />

Steve
--
Steven C. Gallafent - The Computer Guy
st***@compguy.com - http://www.compguy.com/

Have you tried http://www.pairusers.com/? I did. It's nifty!
Jul 17 '05 #3
The getimagesize() function will determine the size of any GIF, JPG, PNG,
SWF, SWC, PSD, TIFF, BMP, IFF, JP2, JPX, JB2, JPC, XBM, or WBMP image file
and return the dimensions along with the file type and a height/width text
string to be used inside a normal HTML IMG tag.

http://ca.php.net/function.getimagesize

Savut

"Ruby Tuesday" <ru*********@yahoo.com> wrote in message
news:c4*************@ID-205437.news.uni-berlin.de...
How do I find the information about an image, e.g. its dimension, whether
it's jpg, tiff, bmp, gif, etc using the
native PHP function? I know that we can do it by using the imagemagick,
but
perhaps some webhosting site does not have that installed. Thanks


Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Martin Zenkel | last post by:
Dear VS Team, using the Beta 2 of VS 2005 I've encontered the following problem. Let's assume threre are three Dll's, one unmanaged and two managed. In the unmanaged we put a simple unmanged...
5
by: Charles A. Lackman | last post by:
Hello, I have created a complete PrintDocument and need to create an image from it. How is this done? e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality...
15
by: dgk | last post by:
I'm trying to save the image of a webbrowser control. Not a particular image being shown on the page, but rather the visible display of the webbrowser. Using VS2005 I figured that maybe...
15
by: Hamed | last post by:
Have I posted the message to wrong newsgroup? Or Does the question is so much strage? Would someone please kindly direct me to a true newsgroup or resource? Best Regards Hamed
1
by: Frijoles | last post by:
Hello, I have a function that accepts an Image as the input. Currently, I load a bitmap in the calling class and pass that in. I'd like to create an overlay with another image and then pass the...
6
by: Blasting Cap | last post by:
I have to change the front page for a sales system I work on, and want to use some thumbnails of wallpaper that is on a sister site. The wallpapers are jpegs, and are 640, 800, 1024 & 1280 in...
6
by: active | last post by:
I have an image and a graphics object created (FromImage) from that image. I need to create a new image and create a new graphics object from the new image. I want the new graphics object have...
6
by: jt | last post by:
i think i was not clear in my quesiton. my question actually was how to store a graphics image generated in C. Eg. #include<graphics.h> void main() { int gm,gd=DETECT; initgraph(&gd,&gm,"");...
9
by: DaveL | last post by:
hello I have a Bit map 1367 wide 32 high this bitmap contains like 40 separate Images 32x32 I tell it the id*32 to get the approiate Image from the source Bitmap When i CreateGraphics()...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.