PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > MIME file and gd
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
MIME file and gd

Réponse
 
LinkBack Outils de la discussion
Vieux 29/03/2008, 01h58   #1
amit
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut MIME file and gd


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



  Réponse avec citation
Vieux 29/03/2008, 02h08   #2
amit
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: MIME file and gd

On Mar 28, 5:58pm, amit <amit.ko...@gmail.com> wrote:
> 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.


  Réponse avec citation
Vieux 29/03/2008, 03h10   #3
petersprc
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: MIME file and gd

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.com> wrote:
> On Mar 28, 5:58 pm, amit <amit.ko...@gmail.com> wrote:
>
>
>
> > 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.


  Réponse avec citation
Vieux 29/03/2008, 03h51   #4
Leandro 'xl3'
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: MIME file and gd

Hi Amit,

For work with images, try this class, has very features.

http://www.verot.net/res/sources/class.upload.html
  Réponse avec citation
Vieux 31/03/2008, 21h35   #5
amit
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: MIME file and gd

On Mar 28, 7:10pm, petersprc <peters...@gmail.com> wrote:
> 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.com> wrote:
>
>
>
> > On Mar 28, 5:58 pm,amit<amit.ko...@gmail.com> wrote:

>
> > > 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 . Very nice function!

Regards,
Amit
  Réponse avec citation
Vieux 31/03/2008, 21h36   #6
amit
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: MIME file and gd

On Mar 28, 7:51pm, "Leandro 'xl3'" <leandro...@gmail.com> wrote:
> HiAmit,
>
> For work with images, try this class, has very features.
>
> http://www.verot.net/res/sources/class.upload.html



Thanks Leandro,

I had no idea there is a class. You both gave very ful
information.

Thanks
Amit
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h15.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12965 seconds with 14 queries