473,385 Members | 1,337 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 3913
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()...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.