By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,637 Members | 2,825 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,637 IT Pros & Developers. It's quick & easy.

[Urgent] Converting an Non-JPEG Image to JPEG

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
*** 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

P: n/a
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

P: n/a
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.