[Urgent] Converting an Non-JPEG Image to JPEG

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ming

    #1

    [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_MagickComma nd = "mogrify -format JPEG ".$FileDest ;
    exec($V2_Magick Command); // I tried to use this to convert the image's
    format (gif) to JPEG but this doesn't work.

    $FileDest2 = "/uploads/1.jpeg";
    $V2_MagickComma nd2 = "convert ".$FileDest ." ".$FileDest 2;
    exec($V2_Magick Command2); // 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!
  • Alvaro G Vicario

    #2
    Re: [Urgent] Converting an Non-JPEG Image to JPEG

    *** Ming wrote/escribió (20 Apr 2004 02:22:57 -0700):[color=blue]
    > 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.[/color]

    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
    --

    Comment

    • Ming

      #3
      Re: [Urgent] Converting an Non-JPEG Image to JPEG

      Alvaro G Vicario <alvaro_QUITAR_ REMOVE@telecomp uteronline.com> wrote in message news:<13yipqrls tgdd$.1egsgnr69 663i.dlg@40tude .net>...[color=blue]
      > *** Ming wrote/escribió (20 Apr 2004 02:22:57 -0700):[color=green]
      > > 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.[/color]
      >
      > 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.
      >
      >
      > --[/color]

      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?

      Comment

      • Justin Koivisto

        #4
        Re: [Urgent] Converting an Non-JPEG Image to JPEG

        Ming wrote:[color=blue]
        > 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?[/color]

        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 - spam@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/

        Comment

        Working...