Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Re: Create Thumbnail

    If you can use GD2 library use this function

    function create_resampled_image($max_height, $max_width, $image_quality,
    $image, $newimage){
    $src_img = imagecreatefromjpeg($image);
    $orig_x = imagesx($src_img);
    $orig_y = imagesy($src_img);

    $new_y = $max_height;
    $new_x = $orig_x/($orig_y/$max_height);

    if ($new_x > $max_width) {
    $new_x = $max_width;
    $new_y = $orig_y/($orig_x/$max_width);
    }

    $dst_img = imagecreatetruecolor($new_x,$new_y);
    imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_x, $new_y, $orig_x,
    $orig_y);
    imagejpeg($dst_img, $newimage, $image_quality);
    imagedestroy($src_img);
    imagedestroy($dst_img);
    }


    Juz Guest

  2. Similar Questions and Discussions

    1. [PHP] PDF Thumbnail with PHP?
      Unfortunatly, that's not what I'm trying to do. That function will add an image to a PDF file as a thumbnail. What I want to do, is read a PDF...
    2. for to create thumbnail by imagemagick gd netpbm ?
      for to resize and copy original photos into a new directory and to use for a thumbnail gallery on the web; who is better GD, Netpbm or...
    3. Image::Magick::Thumbnail::create problem
      I am using a script based on the example from www.cpan.org for Image::Magick::Thumbnail:- #!/usr/bin/perl -w use CGI qw(:all); print header;...
    4. any easy library to create a thumbnail
      Hi all, I am trying to convert my gifs and png to thumbnails Does anyone know a library that can help me Thanks Ram
    5. PDF Thumbnail with PHP?
      Does anyone know if there is a way to generate a thumbnail of the 1st page of a PDF document using PHP. I have an application that archives PDF...
  3. #2

    Default Re: Create Thumbnail

    > I'm looking for exactly the following script
    > [url]http://alt-php-faq.org/local/105/[/url].
    > But the quality of the result is horrible.
    replace line $dst_img = imagecreate($new_w,$new_h);
    with line $dst_img = imagecreatetruecolor($new_w,$new_h);

    you may also build a x2 thumbnail

    imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w* 2,$new_h*2,imagesx($src_im
    g),imagesy($src_img));

    and display it with width=$new_w, height=$new_h

    Guillaume
    [url]www.designerspace.com[/url]



    Guillaume JANY Guest

  4. #3

    Default Re: Create Thumbnail

    I have written a script for a commercial website to resize images. If you
    still want it email me at [email]ski_sanjay@yahoo.com[/email]

    sanjay


    "Thür Thomas" <thomasFUCKK@SSPAMMMthuer.com> wrote in message
    news:3f0c927e$0$22092$5402220f@news.sunrise.ch...
    > Hello NG
    >
    > I'm looking for exactly the following script
    > [url]http://alt-php-faq.org/local/105/[/url].
    > But the quality of the result is horrible.
    > The original pic: [url]http://www.neonthaler.ch/test/moose.jpg[/url]
    > The small pic: [url]http://www.neonthaler.ch/test/moose2.jpg[/url]
    >
    > Has someone a script with the same function and better results?
    >
    > Thx for your help.
    > Thomas
    >
    >

    s a n j a y Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139