EzDevInfo.com

PHPThumb

PHP Thumbnail & Image Manipulation Library

Is phpThumb still a good solution? [closed]

A long time ago I used a PHP library called phpThumb to show different sizes of my images on my website.

Today I need to do the same. Googling phpThumb gave me 2 results:

Are they the same?

Should I stick to phpThumb, or is there a better library today?


Source: (StackOverflow)

phpThumb PDF thumbnail

I am using phpThumb to create thumbnails of PDFs uploaded to my site.

This is working for some PDFs but others produce an error that states imagemagick and or ghostscript are unavailable.

These should be available as phpThumb is using these for the working PDF thumbnails.

One thing that I have noticed is that it tends to be PDFs that are generated on a Mac that are causing the problem. Does anybody know of a fix to this?

Thanks.


Source: (StackOverflow)

Advertisements

PHP thumb resize png image but add black background

I am using PHPThumb to resize images rumtime. It is working fine but it add black background on PNG image. How could I resolve this? my path is

phpThumb/phpThumb.php?src={imagepath}&w=95&h=92

Source: (StackOverflow)

How to integrate phpThumb into a CodeIgniter application's architecture?

I'd like to use phpThumb ( http://phpthumb.sourceforge.net/ ) on my view layer to automatically size some images.

What's the recommended way to integrate phpThumb into the CodeIgniter architecture? Has anyone done this already and found that you prefer one method of integration over another?

I'm basically looking for opinions on using phpThumb as a helper/library/as-is code, etc.


Source: (StackOverflow)

Switching on error messages in phpThumb

How so I do this? I looked at phpThumb.php and the following is set, so I don't know why I am getting the error on my demo page

ini_set('display_errors', 1); 
error_reporting(E_ALL); 

Source: (StackOverflow)

best practice of generating thumbnail?

I am creating a social network where users upload their profile image.

This image will be used in their profile page in 150 / 150 px dimension.

In the home page i.e user Activity feed I need the same image to be in 75 / 75 px.

What would be the best practice to do this

  1. Resize image on fly (timthumb).
  2. Resize and Save image in the server.

Source: (StackOverflow)

Jquery; Chrome Image Width and Height = 0 for new Image()

Im having trouble getting Chrome to recognize an Image width or height after the DOM has loaded. The Image is dynamically loaded through phpThumb script (which resizes the image). If I take away the dynamic url and just replace it with the Image's direct url I get no issues and everything works in Chrome but with the dynamic url, chrome doesn't seem to be able to calculate the image width or height.

Anyone have any experience with this? Its doing my head in.

The code in question is :

var theImage     = new Image();
theImage.src     = $image.attr('src');
var imgwidth     = theImage.width;
var imgheight    = theImage.height;

Where imgwidth = 0; for chrome, yet IE, Firefox both report the correct size.


Source: (StackOverflow)

clear phpThumb cache regularly with cron job

I am using phpThumb on a client website, and as it is a very image heavy application the cache gets huge quick. Today the thumbs stopped working and I had rename the cache folder, as the folder was too big to delete via ftp. I renamed it cache_old and am trying to delete it now via ssh. I recreated the cache folder and everything worked fine again.

Since it seems it stops working when the cache folder is too full, plus just to keep the server tidy, I would like to setup a daily cron job to clear files from the cache folder. I have no idea how to do this though and haven't been able to find an answer yet..

The cache folder has a file in it called index.php which I assume needs to stay, plus a sub folder called source, which again has a file called index.php, again I assumed that needs to be there. So I need a command that will delete everything BUT those files.

Any guidance on how to set this up would be appreciated!

Thanks, Christine

P.S. The site is hosted on DreamHost, and I have set other jobs up via there cronjob panel, and I do have SSH access if setting it up that way is easier. Cheers!!


Source: (StackOverflow)

Regex to GENERATE thumbnails!?!?! (but that's crazy!)

So here is my situation, and the solution that I've come up with to solve the problem. I have created an application that includes TinyMCE to allow users to create HTML content for publishing. The user can include images in their markup, and drag/resize those images affecting the final Width/Height attributes in the IMG tag. This is all great, the users can include images and resize/relocate them to their desired appearance. But one big problem is that I am now sending a (possibly) much larger image to the client, only to have the browser resize the image into the requested Width/Height attributes. All that bandwidth and lost load time....

So my solution is to pre-process my users markup content, scanning all of the IMG tags and parsing out the Height/Width/Src attributes. Then set each img's SRC tag to a phpThumb request with the parsed Height/Width passed into the thumbnails URL. This will create my reduced size image (optimising bandwidth at the expense of CPU and caching). What do you think about this solution? I've seen other posts where people were using mod_rewrite to do something similar, but I want to affect the content on the page service and not manipulate the image requests as they're being received. .... Any thoughts about this design?

I need some help with the fine details as my regex skills need some work, but I'm very short on time and promise to pay my technical knowledge debt soon. To make the regex's easier, I can be sure of some things. Only img tags that need this processing will have an existing width="" height="" attributes (with the double quotes, and lower cased text, but I suppose matching the text case insensitive would be better if TinyMCE changes)

So a regex to match only the necessary Img tags, and maybe another three regex's to extract the src, the width, and the height?

Thanks everyone.


Source: (StackOverflow)

phpThumb not working for large images on server

I have spent a lot time by searching and trying different options but with no luck :( phpThumb is working like a charm on development machine but on server it fails with no error.I am using ajaxForm to upload image.

                $phpThumb->setSourceData($thumb_source_path);
                $phpThumb->setParameter('w', 180);
                $phpThumb->setParameter('h', 160);
                $phpThumb->setParameter('zc', true);
                $output_filename = $imgThumbPath;
                if ($phpThumb->GenerateThumbnail()) { 

                    if ($phpThumb->RenderToFile($output_filename))
                    {

                    }
                } else {

                    echo 'Failed:<pre>'.$phpThumb->fatalerror."\n\n".implode("\n\n", $phpThumb->debugmessages).'</pre>';
                }

phpThumb.demo.check.php result


Source: (StackOverflow)

Can phpthumb generate interlaced images for progressive browser display?

Is it possible to generate interlaced images using phpthumb? Even if phpthumb doesn't generate interlaced images is there a safe walk-around that can be used to achieve this on a webapp that uses phpthumb for image processing?

I tried finding out if phpthumb has this feature and all i could come up with was this configuration directive in phpThumb.config.php file:

$PHPTHUMB_CONFIG['output_interlace'] = true;   // if true: interlaced output for GIF/PNG, progressive output for JPEG; if false: non-interlaced for GIF/PNG, baseline for JPEG.

I set mine to true and it is still not generating interlaced images.


Source: (StackOverflow)

Using PHPThumb and Thickbox/Colorbox

When linking to a resized image by PHPThumb to popup in a lightbox using either thickbox or colorbox, I am getting a lightbox come up with data and characters. I am guessing because thickbox does not see my image as a real image because it is outputted with the php extension:

includes/phpThumb/phpThumb.php?src=includes/kcfinder/upload/files/1209679628284.jpg&w=800&h=600&zc=1

Anybody know a solution?

Also, is using PHPThumb for a content management system a good idea? Would just resizing the image to multiple sizes work better on more setups/server configs?

LINK: http://jeffkilroy.com/hosted/ImageIssue/test.php


Source: (StackOverflow)

Thumb nail form flv file

I am making a websit in which client want to show video gallery like u tube . on internet i found use of ffmpeg. i have download ffmpeg adn pest it in root directry. and create class

  <?php
          class media_handler
          {
                 function convert_media($filename, $rootpath, $inputpath,$outputpath,$width, $height, $bitrate, $samplingrate)
          {
            $outfile = "";

                  $rPath = $rootpath."\ffmpeg";

                $size = $width."x".$height;

                     $outfile =$filename;




                 $size = Width & "x" & Height;



                     $outfile = 'out_file.flv';


               $ffmpegcmd1 = "ffmpeg -i '".$inputpath."'\'".$filename. "' -acodec mp3    -ar '" .$samplingrate."' -ab '".$bitrate."'
                   -f flv -s '".$size."' '".$outputpath."'\'".$outfile;
               $ret = shell_exec($ffmpegcmd1);


                   return $outfile;
                     }


                  function set_buffering($filename,$rootpath,$path)
                   {

                   $_rootPath = $rootpath."\flvtool";



                 $ffmpegcmd1 = "flvtool2 -U '".$Path."'\'".$filename;
                     $ret = shell_exec($ffmpegcmd1);


                }



                      function grab_image($filename, $rootpath, $inputpath,$outputpath, $no_of_thumbs, $frame_number, $image_format, $width, $height)
               {

                       $_rootpath ="ffmpeg";

                  $size = $width. "x".$height;


                  $outfile = "sample.png";

                     $ffmpegcmd1 = "ffmpeg -i '".$inputpath."'\'".$filename."' -vframes '".$no_of_thumbs."' -ss 00:00:03 -an -vcodec '". $image_format."' -frawvideo -s '".$size. "''". $outputpath."'\'".$outfile ;

               $ret = shell_exec($ffmpegcmd1);



                return $outfile;
             }
                     }

and where i have used this the code is

                      $outfile=$_FILES['videofile']['name'];
$rootpath =$videoPath;
$outputpath=$videoPath;
$thumbpath=$videoPath;
     **$image_name = $_mediahandler->grab_image($outfile, $rootpath, $outputpath, $thumbpath, 1, 2, "png", 110, 90);**

but it is not working .


Source: (StackOverflow)

phpThumb cache problems

I'm using phpThumb - the PHP thumbnail generator.

'phpThumb.config.php':

$PHPTHUMB_CONFIG['cache_maxage'] = 10; 

$PHPTHUMB_CONFIG['cache_maxsize'] = 1000; 

$PHPTHUMB_CONFIG['cache_maxfiles'] = 10;   

but it does nothing... I've got 108 MB in 922 files... and it keeps growing.


Source: (StackOverflow)

How to generate Thumbnails with phpThumb and save it into a file?

i wan't to know how to generate thumbnails with phpThumb Class, with an array with file paths already. And then Save the result of each image on other path but with the same name.

Thank you all ;)

EDIT: I have my code something like this:

    echo "A iniciar gerador de miniaturas para a área de cliente: \n";
    include $wincli['files']['phpThumbClass'];
    $files = file_list($wincli['dirs']['logos']);

    $phpThumb = new phpThumb();
    foreach( $files as $file ) {
        echo "  # A converter o ficheiro '".basename($file)."' : ";
        if(is_file($file)){         
            $phpThumb->setSourceFilename($file); 
            $phpThumb->setParameter('w', 880);
            $phpThumb->setParameter('h', 241);
            $phpThumb->setParameter('q', 90);
            $phpThumb->setParameter('zc', 1);
            $outputFilename = $wincli['dirs']['logosthumbs'].$file;

            if($phpThumb->GenerateThumbnail()){
                if($phpThumb->RenderToFile($outputFilename)){
                    echo "OK \n";
                }else{
                    echo "Falhou (Ao guardar no ficheiro)\n";
                }
            }else{
                echo "Falhou (Ao gerar miniatura)\n";
            }
        }else{
            echo "Falhou (Ficheiro inexistente)\n";
        }
    }

This is the Debug:

phpThumb() v1.7.7-200612252156 in file "phpthumb.class.php" on line 216
setSourceFilename(/var/www/virtual/test.com/wincli/logos/001-0.jpg) set $this->sourceFilename to "/var/www/virtual/test.com/wincli/logos/001-0.jpg" in file "phpthumb.class.php" on line 234
  file_exists() = 0 in file "phpthumb.class.php" on line 1036
is_executable() = 0 in file "phpthumb.class.php" on line 1037
ImageMagickThumbnailToGD() aborting because cannot find convert in $this->config_imagemagick_path (), and `which convert` returned () in file "phpthumb.class.php" on line 1066
$AvailableImageOutputFormats = array(text;ico;bmp;wbmp;gif;png;jpeg) in file "phpthumb.class.php" on line 825
$this->thumbnailFormat set to $this->config_output_format "jpeg" in file "phpthumb.class.php" on line 835
$this->thumbnailQuality set to "90" in file "phpthumb.class.php" on line 852
!$this->config_allow_src_above_docroot therefore setting "/var/www/virtual/test.com/wincli/logos/001-0.jpg" (outside "/var/www/virtual/test.com/htdocs") to null in file "phpthumb.class.php" on line 1001
$this->sourceFilename set to "" in file "phpthumb.class.php" on line 754
phpThumb() v1.7.7-200612252156

"" does not exist in file "phpthumb.class.php" on line 3404
setCacheDirectory() starting with config_cache_directory = "" in file "phpthumb.class.php" on line 859
$this->config_cache_directory () is not a directory in file "phpthumb.class.php" on line 895
SetCacheFilename() failed because $this->config_cache_directory is empty in file "phpthumb.class.php" on line 2808
starting ExtractEXIFgetImageSize() in file "phpthumb.class.php" on line 2665
GetImageSize("") failed in file "phpthumb.class.php" on line 2688
$this->useRawIMoutput=false because "fltr" is set in file "phpthumb.class.php" on line 1151
ImageMagickThumbnailToGD() aborting because $this->sourceFilename is empty in file "phpthumb.class.php" on line 1196
ImageMagickThumbnailToGD() failed in file "phpthumb.class.php" on line 2695
SetOrientationDependantWidthHeight() starting with ""x"" in file "phpthumb.class.php" on line 2644
SetOrientationDependantWidthHeight() setting w="880", h="241" in file "phpthumb.class.php" on line 2660
EXIF thumbnail extraction: (size=0; type=""; 0x0) in file "phpthumb.class.php" on line 2747
starting SourceImageToGD() in file "phpthumb.class.php" on line 3005
$this->useRawIMoutput=false because "fltr" is set in file "phpthumb.class.php" on line 1151
ImageMagickThumbnailToGD() aborting because $this->sourceFilename is empty in file "phpthumb.class.php" on line 1196
Not using EXIF thumbnail data because $this->exif_thumbnail_data is empty in file "phpthumb.class.php" on line 3046
$this->gdimg_source is still empty in file "phpthumb.class.php" on line 3098
ImageMagickThumbnailToGD() failed in file "phpthumb.class.php" on line 3100
phpThumb() v1.7.7-200612252156

Unknown image type identified by "" () in SourceImageToGD()[3210] in file "phpthumb.class.php" on line 3404
SourceImageToGD() failed in file "phpthumb.class.php" on line 312

Source: (StackOverflow)