473,609 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3928
Continue ...

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

"Ruby Tuesday" <ru*********@ya hoo.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*********@ya hoo.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 = imagecreatefrom jpeg($source_fi le);
$old_width = imagesx($old_im age);
$old_height = imagesy($old_im age);

// Create blank image
$new_image = imagecreatetrue color($new_widt h,$new_height);

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

imagecopyresize d($new_image,$o ld_image,0,0,0, 0,$new_width,$n ew_height,$old_ w
idth,$old_heigh t);
header('Content-type: image/jpeg');
imagejpeg($new_ image);
?>

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

Steve
--
Steven C. Gallafent - The Computer Guy
st***@compguy.c om - 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*********@ya hoo.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
2317
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 struct "A" which is exported in the usual way. The first managed assembly defines a managed class "B" using the unmanaged class "A" defined in the unmanaged Dll. This class "B" has got a public
5
27147
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 e.Graphics.DrawString(Line1.Text, FontLine1, TheBrush, Thelocation1, 390 + yPos, AStringFormat) e.Graphics.DrawString(Line2.Text, FontLine2, TheBrush, Thelocation2, TheHeight1 + (390 + yPos))
15
7183
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 DrawToBitmap would work, but it appears that the webbrowser doesn't implement it. So I looked around and found that this code: Dim g As Graphics g.CopyFromScreen(Me.wb1.PointToScreen(New Point(0, 0)), New Point(0, 0), wb1.Size)
15
1833
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
6310
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 resulting bitmap in to the aforementioned function for it to finish everything. The problem I'm having is that after I combine the two images, I am left with a Graphics object. I can't do a g.DrawImage at this point. I know I can save it to a...
6
1160
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 size, and range from around 100k to about 2 megs. What I want to do is on my web page, keep the aspect ratio, but size them to be no more than 300 pixels wide. I've found some code to do this from a database, but can't find any that
6
1691
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 all the properties of the old graphics object (like PageUnit and InterpolationMode...) Can I do that without setting them all one at a time?
6
4134
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,""); rectangle(50,50,200,300);
9
2643
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() From the Standard CreateGraphics() function the code below works
0
8130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8222
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8406
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5510
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2531
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1389
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.