469,623 Members | 1,416 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

[Urgent] Converting an Non-JPEG Image to JPEG

Hi All,

I want to write a PHP webpage which allows people to upload images (no
matter what formats) to me and at the same time converts any non-jpeg
image to JPEG.

Here's what I have:

$FileDest = "/uploads/1.gif";
if (!move_uploaded_file($_FILES["file"]["tmp_name"], $FileDest)):
$Error = "Yes";
endif; // This will upload an image to /uploads/1.gif

$V2_MagickCommand = "mogrify -format JPEG ".$FileDest;
exec($V2_MagickCommand); // I tried to use this to convert the image's
format (gif) to JPEG but this doesn't work.

$FileDest2 = "/uploads/1.jpeg";
$V2_MagickCommand2 = "convert ".$FileDest." ".$FileDest2;
exec($V2_MagickCommand2); // I also tried to use this to convert the
image's format (gif) to JPEG but this doesn't work, either.

What seems to be wrong? How do I modify my codes to make my uploading
webpage to work?

Any idea is appreciated!
Jul 17 '05 #1
3 2409
*** Ming wrote/escribió (20 Apr 2004 02:22:57 -0700):
I want to write a PHP webpage which allows people to upload images (no
matter what formats) to me and at the same time converts any non-jpeg
image to JPEG.


Some ideas I can think of:

1) You check whether file was uploaded successfully. Then you proceed in
either case.

2) You process all files, even JPEG or Excel ones. You should check
$_FILES['file']['type']

3) Print the command line passed to mogrify to see what it looks like, just
to make sure there aren't simple syntax typos.
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #2
Alvaro G Vicario <al******************@telecomputeronline.com> wrote in message news:<13******************************@40tude.net> ...
*** Ming wrote/escribió (20 Apr 2004 02:22:57 -0700):
I want to write a PHP webpage which allows people to upload images (no
matter what formats) to me and at the same time converts any non-jpeg
image to JPEG.


Some ideas I can think of:

1) You check whether file was uploaded successfully. Then you proceed in
either case.

2) You process all files, even JPEG or Excel ones. You should check
$_FILES['file']['type']

3) Print the command line passed to mogrify to see what it looks like, just
to make sure there aren't simple syntax typos.
--


Some Explanation:

When I tried to convert an image to JPEG (for example, pic.gif to
pic.jpeg), I would get pic.jpeg.0, pic.jpeg.1, pic.jpeg.2, pic.jpeg.3,
pic.jpeg.4, pic.jpeg.5 instead of simply "pic.jpeg".

I don't know why. Any help?
Jul 17 '05 #3
Ming wrote:
Some Explanation:

When I tried to convert an image to JPEG (for example, pic.gif to
pic.jpeg), I would get pic.jpeg.0, pic.jpeg.1, pic.jpeg.2, pic.jpeg.3,
pic.jpeg.4, pic.jpeg.5 instead of simply "pic.jpeg".

I don't know why. Any help?


Was it an animated GIF? could those be each frame of the animation?

Use Image Magick from the command line to first be sure that it is
working as expected. Once that is figured out, then start putting pieces
in your PHP script.

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
SEO Competition League: http://seo.koivi.com/
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by js | last post: by
1 post views Thread by Kathy | last post: by
3 posts views Thread by Parvesh | last post: by
7 posts views Thread by zeyais | last post: by
3 posts views Thread by N. Spiker | last post: by
77 posts views Thread by Hans Schneider | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.