Image Type (photo album)
Moderator: General Moderators
Image Type (photo album)
I need to create a script that resizes images on the fly for a photo album. I am having a little difficulty because I want to output a thumbnail of the images but they could be different file formats.
Is there anyway to detect the file format or work with images other than jpg/gif/bmp/png? I guess maybe this is just a limitation of PHP, but I'd like my photo album to be as accommodating as possible.
Is there anyway to detect the file format or work with images other than jpg/gif/bmp/png? I guess maybe this is just a limitation of PHP, but I'd like my photo album to be as accommodating as possible.
Re: Image Type (photo album)
Nope, thats just you =).ast3r3x wrote:.......I guess maybe this is just a limitation of PHP......
Code: Select all
function file_ext($filename)
{
$exp = explode("e;."e;, $filename);
return $expїsizeof($exp)-1];
}
//sample
echo file_ext('some.image.dot.jpg');Re: Image Type (photo album)
Haha, no no, I know how to get the file extension, and then the type. What I'm saying is...to my (basic I'll admit) understanding of GD is that when you create an image from a file, you need to do imagecreatefrompng/imagecreatefromgif...ect. But how would you load and scale an image that is a psd or another format?qads wrote:Nope, thats just you =).ast3r3x wrote:.......I guess maybe this is just a limitation of PHP......
the above will tell you extension the file has, there are other ways, but this will do.Code: Select all
function file_ext($filename) { $exp = explode("e;."e;, $filename); return $expїsizeof($exp)-1]; } //sample echo file_ext('some.image.dot.jpg');
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
gd cannot load any other formats outside the common ones it handles. If you need more substantive handling, you need something like ImageMagick: http://imagemagick.sf.net
Ok...so I got it working, and it works great, I even figured out a nice way to clear my thumbnails that aren't in use.
See
However, take keen note to how the text looks...pretty good, it's imposed over the image.
Now using the same function, on the same images, I want to know why these images look different. I guess it could be different versions of GD, but should it really matter?[/url]
See
However, take keen note to how the text looks...pretty good, it's imposed over the image.
Now using the same function, on the same images, I want to know why these images look different. I guess it could be different versions of GD, but should it really matter?[/url]
If you grab the image and move it, you'll see the text is part of the image. I decided that the text would be easier to see on a solid background, because you can't control the colors in the picture, so depending, it can be very difficult to read.
I am storing the thumbnails so they don't have to be recreated unless either the thumbnailing script or the original image changes.
The reason you'll see a slow load time (specifically on swigg.net) is because it's hosted off of my computer for the time being.
Do you notice how the text looks different on each page?
I am storing the thumbnails so they don't have to be recreated unless either the thumbnailing script or the original image changes.
The reason you'll see a slow load time (specifically on swigg.net) is because it's hosted off of my computer for the time being.
Do you notice how the text looks different on each page?