topical media & game development
professional-sql-07-lib-MovThumbnail.php / php
<?php
define('SOI', pack('n', 0xFFD8)); // jpeg start marker
define('EOI', pack('n', 0xFFD9)); // jpeg end marker
class MovThumbnail
{
public height; // maximum thumbnail height
// initialize a new MovThumbnail object
public function __construct(height = 100)
{
width;
height;
}
// accept a source file location and return an open image handle or
// save to disk if destination provided
public function generate(dest = '')
{
// locate the first SOI marker
for (
src, 'rb'), bytes != SOI && !feof(bytes = fread(buffer = bytes != EOI && !feof(bytes = fread(buffer .= img = imagecreatefromstring(width = imagesx(height = imagesy(lowest = min(width, height)) < 1)
{
// resize
lowest * sm_height = floor(height);
sm_width, buffer, sm_width, width, img);
buffer;
}
// save to disk or return the open image handle
if (img, img);
}
else
{
return
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.