Hello group,
I'm uploading some image files such as jpeg, png and gif. However, I
must convert time to jpeg type. I have few questions:
1) Can I convert time in using gd library?
2) Currently, I check the MIME file to see what is holding (thanks to
Michael ) like image/jpg or image/gif or image/png. But what should be
the criteria? I'm checking:
if ($img_array_info[mime] == "image/jpg" {
...
}
However, there are some files that rather image/jpg they have image/
jpeg as mime in their headers. Should I compare it agaisnt these two
criteria or there are other things I have to consider too?
Thanks,
Amit 3 1641
On Mar 28, 5:58*pm, amit <amit.ko...@gmail.comwrote:
Hello group,
I'm uploading some image files such as jpeg, png and gif. However, I
must convert time to jpeg type. *I have few questions:
1) Can I convert time in using gd library?
2) Currently, I check the MIME file to see what is holding (thanks to
Michael ) like image/jpg or image/gif or image/png. But what should be
the criteria? I'm checking:
* * * * * if ($img_array_info[mime] == "image/jpg" {
* * * * * * * * * ...
* * * * * }
However, there are some files that rather image/jpg they have image/
jpeg as mime in their headers. Should I compare it agaisnt these two
criteria or there are other things I have to consider too?
Thanks,
Amit
Currently I'm doing this:
if ( (strcasecmp($array_img_information[mime], "image/jpg") == 0 ) ||
(strcasecmp($array_img_information[mime], "image/jpeg") == 0 ) )
{
echo "<br>OK, jpeg file<br>";
}
else
{
echo "<br>$array_img_information[mime]<br>";
echo "<br>Not a jpeg file must conver it!<br>";
}
Is this a proper way or ....?
Thanks again.
Hi,
The best way to get the image type is exif_imagetype. If you don't
have that you can also use getimagesize.
Now, if you want a general way to convert between image types, the
easiest is to use the convert command that comes with ImageMagick.
Here's a function to convert many image types:
<?
function imConvert($path, $newPath)
{
$cmd = 'convert ' . escapeshellarg($path) . ' ' .
escapeshellarg($newPath) . ' 2>&1';
exec($cmd, $output, $exitCode);
if ($exitCode != 0) {
throw new Exception("Command \"$cmd\" failed with " .
"exit code $exitCode: " . join("\n", $output));
}
}
$path = dirname(__FILE__) . '/img.gif';
$newPath = dirname(__FILE__) . '/im.jpg';
imConvert($path, $newPath);
?>
You can also use GD to do this. To convert from GIF to JPEG, you would
call imagecreatefromgif then imagejpeg.
Regards,
John Peters
On Mar 28, 9:08 pm, amit <amit.ko...@gmail.comwrote:
On Mar 28, 5:58 pm, amit <amit.ko...@gmail.comwrote:
Hello group,
I'm uploading some image files such as jpeg, png and gif. However, I
must convert time to jpeg type. I have few questions:
1) Can I convert time in using gd library?
2) Currently, I check the MIME file to see what is holding (thanks to
Michael ) like image/jpg or image/gif or image/png. But what should be
the criteria? I'm checking:
if ($img_array_info[mime] == "image/jpg" {
...
}
However, there are some files that rather image/jpg they have image/
jpeg as mime in their headers. Should I compare it agaisnt these two
criteria or there are other things I have to consider too?
Thanks,
Amit
Currently I'm doing this:
if ( (strcasecmp($array_img_information[mime], "image/jpg") == 0 ) ||
(strcasecmp($array_img_information[mime], "image/jpeg") == 0 ) )
{
echo "<br>OK, jpeg file<br>";}
else
{
echo "<br>$array_img_information[mime]<br>";
echo "<br>Not a jpeg file must conver it!<br>";
}
Is this a proper way or ....?
Thanks again.
On Mar 28, 7:10*pm, petersprc <peters...@gmail.comwrote:
Hi,
The best way to get the image type is exif_imagetype. If you don't
have that you can also use getimagesize.
Now, if you want a general way to convert between image types, the
easiest is to use the convert command that comes with ImageMagick.
Here's a function to convert many image types:
<?
function imConvert($path, $newPath)
{
* $cmd = 'convert ' . escapeshellarg($path) . ' ' .
* * escapeshellarg($newPath) . ' 2>&1';
* exec($cmd, $output, $exitCode);
* if ($exitCode != 0) {
* * throw new Exception("Command \"$cmd\" failed with " .
* * * "exit code $exitCode: " . join("\n", $output));
* }
}
$path = dirname(__FILE__) . '/img.gif';
$newPath = dirname(__FILE__) . '/im.jpg';
imConvert($path, $newPath);
?>
You can also use GD to do this. To convert from GIF to JPEG, you would
call imagecreatefromgif then imagejpeg.
Regards,
John Peters
On Mar 28, 9:08 pm,amit<amit.ko...@gmail.comwrote:
On Mar 28, 5:58 pm,amit<amit.ko...@gmail.comwrote:
Hello group,
I'm uploading some image files such as jpeg, png and gif. However, I
must convert time to jpeg type. *I have few questions:
1) Can I convert time in using gd library?
2) Currently, I check the MIME file to see what is holding (thanks to
Michael ) like image/jpg or image/gif or image/png. But what should be
the criteria? I'm checking:
* * * * * if ($img_array_info[mime] == "image/jpg" {
* * * * * * * * * ...
* * * * * }
However, there are some files that rather image/jpg they have image/
jpeg as mime in their headers. Should I compare it agaisnt these two
criteria or there are other things I have to consider too?
Thanks,
>Amit
Currently I'm doing this:
if ( (strcasecmp($array_img_information[mime], "image/jpg") == 0 ) *||
(strcasecmp($array_img_information[mime], "image/jpeg") == 0 ) )
{
* *echo "<br>OK, jpeg file<br>";}
else
{
* *echo "<br>$array_img_information[mime]<br>";
* *echo "<br>Not a jpeg file must conver it!<br>";
}
Is this a proper way or ....?
Thanks again.- Hide quoted text -
- Show quoted text -
Thanks indeed for your help. Very nice function!
Regards,
Amit This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: clevariant |
last post by:
Hello,
I'm tasked with creating a WSDL file that is compatible with .NET's
code gen' tool, wsdl.exe. I'm getting an error in the code output
saying "Missing soap:body input binding", which...
|
by: Michael Loughry |
last post by:
I'm writing a web application that fetches documents from the server and
sends them to the client. I do this using the Response.BinaryWrite method.
However, is there any way to detect the MIME...
|
by: splodge |
last post by:
This may seem like a stupid question but I want to check before I go
ahead and build this...
I am working on a portal, part of which allows users to upload files.
Part of the array within...
|
by: Datawright |
last post by:
Apologies if this is a daft question but I'm new to c# and everything
is strange to me.
I have written a SOAP Extension class that intercepts a web service
that returns MIME attachmernts as part...
|
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - How do I prompt a "Save As" dialog for an
accepted mime type?...
|
by: comp.lang.php |
last post by:
if (!function_exists('mime_content_type_fileinfo')) {
/**
* Will use {@link http://us2.php.net/fileinfo FileInfo} functions
provided within {@link http://pecl.php.net PECL} bundle to return mime...
|
by: comp.lang.php |
last post by:
<pre>
if (!function_exists('mime_content_type_fileinfo')) {
/**
* Will use {@link http://us2.php.net/fileinfo FileInfo} functions
provided within {@link http://pecl.php.net PECL} bundle to return...
|
by: Mad Hatter |
last post by:
Hi folks
I'm a bit confused with an upload script that I've written. I want to be
able to check the file type of an upload by checking the mime type but I'm
not getting the results that I...
|
by: tinman77 |
last post by:
Hello,
I'm having a terrible time using the functions finfo_open and
finfo_file. I'm using PHP 5 on IIS 5.1 and Windows XP. I have enabled
php_mime_magic.dll and php_fileinfo.dll and also added...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |