Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100 off


PHP Tutorials and Scripts   




Title: Thumbnail and Watermark    Marked Cool    (Review this resource)
Author: emiliort
Posted On: 2005-02-11
Category: Home > PHP Classes

Popularity: 2 points out of 10    

Description: This is a PHP class that can process an image on the fly by either generating a thumbnail and/or apply a watermark to the image. The processed image can either be displayed in a page, saved to a file, or returned to a variable. It requires the PHP with support for GD library extension in either version 1 or 2. If the GD library version 2 is available, the class can manipulate the images in true color, thus providing better quality of the results of resized images.
Features description:
- Thumbnail: normal thumbnail generation
- Watermark: Text or image in PNG format. Suport multiples positions.
- Auto-fitting: adjust the dimensions so that the resized image aspect is not distorted
- Scaling: enlarge and shrink the image
- Format: both JPEG and PNG are supported, but the watermark image can only be in PNG format as it needs to be transparent
- Autodetect the GD library version supported by PHP
- Calculate quality factor for a specific file size in JPEG format.
- Suport bicubic resample algorithm
- Tested: PHP 4 valid


Total Hits: 4155     Total Votes: 0     Total Points: 0 (0 reviews)        [ Download ]   

Page Navigation:  [1]


Docs For Class Thumbnail

Class Thumbnail

Description

This is a PHP class that can process an image on the fly by either generate a thumbnail and/or apply an watermark to the image.

The processed image can either be displayed in a page, saved to a file, or returned to a variable. It requires the PHP with support for GD library extension in either version 1 or 2. If the GD library version 2 is available it the class can manipulate the images in true color, thus providing better quality of the results of resized images. Features description: - Thumbnail: normal thumbnail generation - Watermark: Text or image in PNG format. Suport multiples positions. - Auto-fitting: adjust the dimensions so that the resized image aspect is not distorted - Scaling: enlarge and shrink the image - Format: both JPEG and PNG are supported, but the watermark image can only be in PNG format as it needs to be transparent - Autodetect the GD library version supported by PHP - Calculate quality factor for a specific file size in JPEG format. Based on Shiege Iseng Resize Class and Huda M Elmatsani JPEGReducer class

  • copyright: GNU General Public License (GPL)
  • abstract:
  • version: 1.41 <2005/02/08>
  • author: Emilio Rodriguez <mailto:emiliort@gmail.com>

	
			
Method Summary
boolean Thumbnail (string $imgfile)
void CalculateQFactor (integer $size)
mixed dump ()
boolean process ()
boolean save ([string $save = ""])
void show ()
boolean size_auto ([integer $size = 100])
boolean size_height ([integer $size = 100])
boolean size_width ([integer $size = 100])
Variables
boolean $allow_enlarge = false (line 81)
  • var: allow to enlarge the thumbnail.
  • access: public
string $error_msg = '' (line 146)
  • var: errors mensage
  • access: public
string $img_watermark = '' (line 87)
  • var: [OPTIONAL] set watermark source file, only PNG format [RECOMENDED ONLY WITH GD 2 ]
  • access: public
string $img_watermark_Haling = 'LEFT' (line 97)
  • var: [OPTIONAL] set watermark horizonatal position, LEFT | CENTER | RIGHT
  • access: public
string $img_watermark_Valing = 'TOP' (line 92)
  • var: [OPTIONAL] set watermark vertical position, TOP | CENTER | BOTTON
  • access: public
integer $jpeg_progressive (line 76)
  • var: set JPEG output format to progressive JPEG : 0 = no , 1 = yes
  • access: public
string $memory_limit = '8M' (line 140)
  • var: [OPTIONAL] set maximun memory usage, default 8 MB ('8M'). (use '16M' for big images)
  • access: public
string $output_format = 'JPG' (line 71)
  • var: output format, default JPG, valid values 'JPG' | 'PNG'
  • access: public
integer $quality = 75 (line 66)
  • var: Quality factor for JPEG output format, default 75
  • access: public
string $txt_watermark = '' (line 103)
  • var: [OPTIONAL] set watermark text [RECOMENDED ONLY WITH GD 2 ]
  • access: public
string $txt_watermark_color = '000000' (line 108)
  • var: [OPTIONAL] set watermark text color , RGB Hexadecimal[RECOMENDED ONLY WITH GD 2 ]
  • access: public
integer $txt_watermark_font = 1 (line 113)
  • var: [OPTIONAL] set watermark text font: 1,2,3,4,5
  • access: public
string $txt_watermark_Haling = 'LEFT' (line 123)
  • var: [OPTIONAL] set watermark text horizonatal position, LEFT | CENTER | RIGHT
  • access: public
integer $txt_watermark_Hmargin = 10 (line 128)
  • var: [OPTIONAL] set watermark text horizonatal margin in pixels
  • access: public
string $txt_watermark_Valing = 'TOP' (line 118)
  • var: [OPTIONAL] set watermark text vertical position, TOP | CENTER | BOTTON
  • access: public
integer $txt_watermark_Vmargin = 10 (line 133)
  • var: [OPTIONAL] set watermark text vertical margin in pixels
  • access: public
Methods
Constructor Thumbnail (line 161)

open source image

  • access: public
boolean Thumbnail (string $imgfile)
  • string $imgfile: filename of the source image file
CalculateQFactor (line 351)

Calculate JPEG quality factor for a specific size in bytes

  • access: public
void CalculateQFactor (integer $size)
  • integer $size: maximun file size in bytes
dump (line 266)

return the result thumbnail

  • access: public
mixed dump ()
process (line 297)

generate image

  • access: public
boolean process ()
save (line 277)

save your thumbnail to file

  • access: public
boolean save ([string $save = ""])
  • string $save: output file name
show (line 250)

show your thumbnail, output image and headers

  • access: public
void show ()
size_auto (line 234)

set the biggest width or height for thumbnail

  • access: public
boolean size_auto ([integer $size = 100])
  • integer $size: width or height
size_height (line 196)

set height for thumbnail

  • access: public
boolean size_height ([integer $size = 100])
  • integer $size: height
size_width (line 215)

set width for thumbnail

  • access: public
boolean size_width ([integer $size = 100])
  • integer $size: width


Page Navigation:  [1]



© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.