imagecopyresampled() Help Needed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ralphNOSPAM@primemail.com

    imagecopyresampled() Help Needed

    When I execute this script, nothing displays on my browser. I'm trying
    to verify my image is being reduced by 50% before I try to write it to
    a file:

    // The file
    $filename = "/home/public_html/radar2.jpg";
    $percent = 0.5;
    // Content type
    header('Content-type: image/jpeg');
    // Get new dimensions
    list($width, $height) = getimagesize($f ilename);
    $new_width = $width * $percent;
    $new_height = $height * $percent;
    // Resample
    $image_p = imagecreatetrue color($new_widt h, $new_height);
    $image = imagecreatefrom jpeg($filename) ;
    imagecopyresamp led($image_p, $image, 0, 0, 0, 0, $new_width,
    $new_height, $width, $height);
    // Output
    imagejpeg($imag e_p, null, 100);

  • Janwillem Borleffs

    #2
    Re: imagecopyresamp led() Help Needed

    ralphNOSPAM@pri memail.com wrote:[color=blue]
    > When I execute this script, nothing displays on my browser. I'm trying
    > to verify my image is being reduced by 50% before I try to write it to
    > a file:
    >[/color]

    Two things you can try:

    1. Use an empty string as the second parameter (as the manual suggests):

    imagejpeg($imag e_p, '', 100);

    2. Send a Content-Type header (combined with suggestion #1):

    header("Content-Type: image/jpeg");
    imagejpeg($imag e_p, null, 100);


    JW



    Comment

    • Janwillem Borleffs

      #3
      Re: imagecopyresamp led() Help Needed

      Janwillem Borleffs wrote:[color=blue]
      > header("Content-Type: image/jpeg");
      > imagejpeg($imag e_p, null, 100);
      >[/color]

      That should be:

      header("Content-Type: image/jpeg");
      imagejpeg($imag e_p, '', 100);


      JW



      Comment

      • Tom Scales

        #4
        Re: imagecopyresamp led() Help Needed


        "Janwillem Borleffs" <jw@jwscripts.c om> wrote in message
        news:43399eff$0 $97550$dbd4d001 @news.euronet.n l...[color=blue]
        > Janwillem Borleffs wrote:[color=green]
        >> header("Content-Type: image/jpeg");
        >> imagejpeg($imag e_p, null, 100);
        >>[/color]
        >
        > That should be:
        >
        > header("Content-Type: image/jpeg");
        > imagejpeg($imag e_p, '', 100);
        >
        >
        > JW
        >
        >
        >[/color]

        I just use:

        imagejpeg($imag e_p);

        For a browser, there is no need to specify quality. Just let it default.
        100 is overkill for a browser anyway.

        Tom


        Comment

        • chotiwallah

          #5
          Re: imagecopyresamp led() Help Needed


          Tom Scales wrote:[color=blue]
          > "Janwillem Borleffs" <jw@jwscripts.c om> wrote in message
          > news:43399eff$0 $97550$dbd4d001 @news.euronet.n l...[color=green]
          > > Janwillem Borleffs wrote:[color=darkred]
          > >> header("Content-Type: image/jpeg");
          > >> imagejpeg($imag e_p, null, 100);
          > >>[/color]
          > >
          > > That should be:
          > >
          > > header("Content-Type: image/jpeg");
          > > imagejpeg($imag e_p, '', 100);
          > >
          > >
          > > JW
          > >
          > >
          > >[/color]
          >
          > I just use:
          >
          > imagejpeg($imag e_p);
          >
          > For a browser, there is no need to specify quality. Just let it default.
          > 100 is overkill for a browser anyway.
          >
          > Tom[/color]

          another tought: how big are your images? php runs out of memory pretty
          quickly if you use truecolor images.

          micha

          Comment

          • ralphNOSPAM@primemail.com

            #6
            Re: imagecopyresamp led() Help Needed

            On 28 Sep 2005 00:58:43 -0700, "chotiwalla h" <chotiwallah@we b.de>
            wrote:
            [color=blue]
            >
            >Tom Scales wrote:[color=green]
            >> "Janwillem Borleffs" <jw@jwscripts.c om> wrote in message
            >> news:43399eff$0 $97550$dbd4d001 @news.euronet.n l...[color=darkred]
            >> > Janwillem Borleffs wrote:
            >> >> header("Content-Type: image/jpeg");
            >> >> imagejpeg($imag e_p, null, 100);
            >> >>
            >> >
            >> > That should be:
            >> >
            >> > header("Content-Type: image/jpeg");
            >> > imagejpeg($imag e_p, '', 100);
            >> >
            >> >
            >> > JW
            >> >
            >> >
            >> >[/color]
            >>
            >> I just use:
            >>
            >> imagejpeg($imag e_p);
            >>
            >> For a browser, there is no need to specify quality. Just let it default.
            >> 100 is overkill for a browser anyway.
            >>
            >> Tom[/color]
            >
            >another tought: how big are your images? php runs out of memory pretty
            >quickly if you use truecolor images.
            >
            >micha[/color]


            The files are 25k to 50k so they are not that big. I came across a
            class php script called ImageEditor.php and it works great at resizing
            images as well as having many other features - so I am using that.

            Comment

            • Tom Scales

              #7
              Re: imagecopyresamp led() Help Needed


              "chotiwalla h" <chotiwallah@we b.de> wrote in message
              news:1127894323 .027751.119330@ o13g2000cwo.goo glegroups.com.. .[color=blue]
              >
              > Tom Scales wrote:[color=green]
              >> "Janwillem Borleffs" <jw@jwscripts.c om> wrote in message
              >> news:43399eff$0 $97550$dbd4d001 @news.euronet.n l...[color=darkred]
              >> > Janwillem Borleffs wrote:
              >> >> header("Content-Type: image/jpeg");
              >> >> imagejpeg($imag e_p, null, 100);
              >> >>
              >> >
              >> > That should be:
              >> >
              >> > header("Content-Type: image/jpeg");
              >> > imagejpeg($imag e_p, '', 100);
              >> >
              >> >
              >> > JW
              >> >
              >> >
              >> >[/color]
              >>
              >> I just use:
              >>
              >> imagejpeg($imag e_p);
              >>
              >> For a browser, there is no need to specify quality. Just let it default.
              >> 100 is overkill for a browser anyway.
              >>
              >> Tom[/color]
              >
              > another tought: how big are your images? php runs out of memory pretty
              > quickly if you use truecolor images.
              >
              > micha
              >[/color]

              Really? I use images in the 75-150K range and have no problems. I load 20
              per page and resize them dynamically to thumbnails.



              Comment

              Working...