Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90560246
thumbmaker.wml
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 2, 18:40
Size
5 KB
Mime Type
text/x-c
Expires
Mon, Nov 4, 18:40 (2 d)
Engine
blob
Format
Raw Data
Handle
22094073
Attached To
R3600 invenio-infoscience
thumbmaker.wml
View Options
## $Id$
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## The CDSware is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
## read config variables:
#include "config.wml"
#include "configbis.wml"
<protect>#!</protect><PHP> -q
<?
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
########################################################
#
# Description: Creates GIF thumbnails of bigger size x pixels
# Works for both gif and jpeg pictures
# This scripts needs many local programs to work: jpegsize,
# djpeg, pnmscale, ppmtogif, ppmquant, gifrsize, convert
# The path to these programs are stored in the config_XXX.php
# Creator: T.Baron
#
# INPUT: $1->Path to picture file
# $2->Path to resulting thumbnail
# $3->largest size (in pixels)
#
# OUTPUT: thumbnail file at $2
#
########################################################
</protect>
$DJPEG="<DJPEG>";
$CONVERT="<CONVERT>";
$GIFTEXT="<GIFTEXT>";
$JPEGSIZE="<JPEGSIZE>";
$PNMSCALE="<PNMSCALE>";
$PPMQUANT="<PPMQUANT>";
$PPMTOGIF="<PPMTOGIF>";
$GIFINTER="<GIFINTER>";
$GIFRSIZE="<GIFRSIZE>";
<protect>
if ($DJPEG == "")
{
print "\nthumbmaker: Cannot find djpeg\n";
exit;
}
if ($CONVERT == "")
{
print "\nthumbmaker: Cannot find convert\n";
exit;
}
if ($GIFTEXT == "")
{
print "\nthumbmaker: Cannot find giftext\n";
exit;
}
if ($JPEGSIZE == "")
{
print "\nthumbmaker: Cannot find jpegsize\n";
exit;
}
if ($PNMSCALE == "")
{
print "\nthumbmaker: Cannot find pnmscale\n";
exit;
}
if ($PPMQUANT == "")
{
print "\nthumbmaker: Cannot find ppmquant\n";
exit;
}
if ($PPMTOGIF == "")
{
print "\nthumbmaker: Cannot find ppmtogif\n";
exit;
}
if ($GIFINTER == "")
{
print "\nthumbmaker: Cannot find gifinter\n";
exit;
}
if ($GIFRSIZE == "")
{
print "\nthumbmaker: Cannot find gifrsize\n";
exit;
}
if ( count($argv) != 4 )
{
print "usage : thumbmaker <path_to_picture> <path_to_thumbnail> "
. "<max_thumbnail_size>\n";
exit;
}
else
{
$picture=$argv[1];
$thumbnail=$argv[2];
$maxsize=$argv[3];
}
#######################################################
#
# Main script
#
#######################################################
#get extension
$extension = ereg_replace(".*\.","",$picture);
$ext = strtolower($extension);
if ($ext != "gif"
&& $ext != "jpeg"
&& $ext != "jpg"
&& $ext != "pdf"
&& $ext != "ps" )
{
print "$0: works only with GIF, PDF, PS or JPEG formats!!!\n";
exit;
}
if ( $ext == "pdf" )
{
$newname = str_replace(".pdf",".gif",$picture);
$isPDF = TRUE;
system("$CONVERT pdf:$picture gif:$newname");
$picture = $newname;
$ext = "gif";
}
elseif ( $ext == "ps" )
{
$newname = str_replace(".ps",".gif",$picture);
$isPDF = TRUE;
system("$CONVERT ps:$picture gif:$newname");
$picture = $newname;
$ext = "gif";
}
else
$isPDF = FALSE;
#get picture size
if ($ext == "gif")
{
$imagesize=`$GIFTEXT $picture | grep "Image Size"`;
$imagesize = ereg_replace("\n.*","",$imagesize);
$width = ereg_replace(".*Width = ","",$imagesize);
$width = ereg_replace(" Height.*","",$width);
$height = ereg_replace(".*Height = ","",$imagesize);
$height = ereg_replace("\..*","",$height);
}
else
{
$imagesize=`$JPEGSIZE $picture`;
$width = ereg_replace(" .*","",$imagesize);
chop($width);
$height = ereg_replace(".* ","",$imagesize);
chop($height);
}
#process scale factor
if ( $width > $height )
$originalmaxsize = $width;
else
$originalmaxsize = $height;
$scale = $maxsize/$originalmaxsize;
#create gif picture if jpeg + transform interlaced gif
$basename = ereg_replace("\.$extension","",$picture);
if ( $ext == "jpg" || $ext == "jpeg" )
system("$DJPEG $picture | $PNMSCALE"
. " $scale | $PPMQUANT 256 | "
. "$PPMTOGIF > $thumbnail");
else
{
system("$GIFINTER $picture > ${basename}_TMfinal.gif");
#create final thumbnail
system("$GIFRSIZE -s $scale ${basename}_TMfinal.gif "
. "> $thumbnail");
system("rm -r ${basename}_TMfinal.gif");
}
if ($isPDF == TRUE)
system("rm $picture");
</protect>
?>
Event Timeline
Log In to Comment