Skip to main content

Resize Images (create thumbnails)

This script will take any image and automatically create a thumbnail of any size you want.   The instructions for using this script are in the comment lines at the top of the script.

- - Start Script Here - -
<?// this script creates a thumbnail image from an image file - can be a .jpg .gif or .png file
// where $thumbsize is the maximum width or height of the resized thumbnail image
// where this script is named resize.php
// call this script with an image tag
// <img src="resize.php?path=imagepath"> where path is a relative path such as subdirectory/image.jpg
$thumbsize = 200;$imagesource =  $_GET['path'];$filetype = substr($imagesource,strlen($imagesource)-4,4);$filetype = strtolower($filetype);
if(
$filetype == ".gif")  $image = @imagecreatefromgif($imagesource);
if(
$filetype == ".jpg")  $image = @imagecreatefromjpeg($imagesource);
if(
$filetype == ".png")  $image = @imagecreatefrompng($imagesource);
if (!
$image) die();$imagewidth = imagesx($image);$imageheight = imagesy($image);
if (
$imagewidth >= $imageheight) {
  
$thumbwidth = $thumbsize;
  
$factor = $thumbsize / $imagewidth;
  
$thumbheight = $imageheight * $factor;
}
if (
$imageheight >= $imagewidth) {
  
$thumbheight = $thumbsize;
  
$factor = $thumbsize / $imageheight;
  
$thumbwidth = $imagewidth * $factor;
}
$thumb = @imagecreatetruecolor($thumbwidth,$thumbheight);imagecopyresized($thumb, $image, 0, 0, 0, 0, $thumbwidth, $thumbheight, $imagewidth, $imageheight);imagejpeg($thumb);imagedestroy($image);imagedestroy($thumb);?>

- - End Script Here - -

Watermark Images
The best way to protect your images is to watermark them.  But that can be a real hassle.  This script will take any image and automatically add a watermark before it is delivered from the server to the person's browser.  The instructions for using this script are in the comment lines at the top of the script.  You can see a sample below.  You can download the sample (mostly transparent) watermark gif image here.


- - Start Script Here - -
<?php// this script creates a watermarked image from an image file - can be a .jpg .gif or .png file
// where watermark.gif is a mostly transparent gif image with the watermark - goes in the same directory as this script
// where this script is named watermark.php
// call this script with an image tag
// <img src="watermark.php?path=imagepath"> where path is a relative path such as subdirectory/image.jpg
$imagesource =  $_GET['path'];$filetype = substr($imagesource,strlen($imagesource)-4,4);$filetype = strtolower($filetype);
if(
$filetype == ".gif")  $image = @imagecreatefromgif($imagesource);
if(
$filetype == ".jpg")  $image = @imagecreatefromjpeg($imagesource);
if(
$filetype == ".png")  $image = @imagecreatefrompng($imagesource);
if (!
$image) die();$watermark = @imagecreatefromgif('watermark.gif');$imagewidth = imagesx($image);$imageheight = imagesy($image); $watermarkwidth =  imagesx($watermark);$watermarkheight =  imagesy($watermark);$startwidth = (($imagewidth - $watermarkwidth)/2);$startheight = (($imageheight - $watermarkheight)/2);imagecopy($image, $watermark,  $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight);imagejpeg($image);imagedestroy($image);imagedestroy($watermark);?>

- - End Script Here - -

The script centers the watermark, but can easily be modified to place it along any edge if you would prefer a different location.   For example removing the "/2" in the $startwidth and $startheight variable calculations will put the watermark in the lower right corner.

You can then make the original images inaccessible if you put the following lines in a .htaccess file in the directory with the images:

RewriteEngine On
RewriteCond %{REQUEST_URI} !error.gif$ RewriteRule \.(gif|jpg|png)$ /error.gif [L]


This will redirect any attempt to directly access an image in that directory to the error image specified.   Note that the error image is specified on two lines in the .htaccess file.   The first line allows the error image to bypass the rewrite.

Comments

Popular posts from this blog

links

0.  https://michael67654.qowap.com/64523001/new-pos-technique-to-perk-up-your-company 1.  https://johnnydinqr.blog2learn.com/52856602/new-pos-system-to-perk-up-your-company 2.  http://edwinsqgcu.onesmablog.com/New-POS-Process-to-Perk-Up-Your-company-43309737 3.  http://chloe69246.bloguetechno.com/New-POS-Process-to-Perk-Up-Your-Business-39814721 4.  http://jacob87541.pointblog.net/New-POS-Technique-to-Perk-Up-Your-online-business-43741223 5.  http://arlette53302.thezenweb.com/New-POS-System-to-Perk-Up-Your-online-business-41464611 6.  http://devinpixna.tinyblogging.com/New-POS-Program-to-Perk-Up-Your-online-business-46354577 7.  https://rylanevsom.blog5.net/46759651/new-pos-program-to-perk-up-your-small-business 8.  https://mariowoesh.affiliatblogger.com/56515206/new-pos-system-to-perk-up-your-organization 9.  https://liam66429.diowebhost.com/60164326/new-pos-procedure-to-perk-up-your-company 10.  https://henry19219.fitnell.com/4557...

Raisonnement, la résolution de problèmes

Les chercheurs ont d'abord développé des algorithmes mimétiques raisonnement humain étapes que les gens utilisent pour résoudre le casse-tête ou faire méthode d'exclusion logique. [2] Dans les années 1980 et 1990 fin, l'étude de la grippe aviaire a développé des méthodes de traitement de l'information incertaine ou incomplète, en utilisant des concepts de probabilité et de l'économie. [3] Pour ces problèmes, les algorithmes requis matériel assez puissant pour effectuer des calculs de géant - à subir « combinaisons d'explosion »: la quantité de mémoire et le temps de calcul peut devenir invisible prendre si la résolution d'un problème difficile. La plus haute priorité est l'algorithme de recherche pour résoudre le problème.  Les gens utilisent généralement les jugements rapides et intuitifs plutôt que pas de déduction que les chercheurs en IA d'origine peuvent simuler. [5] Amnesty International a progressé en utilisant la résolution de problèmes « c...

21 "teure" Arbeitsplätze in der Zukunft, vielversprechend und nur schwer durch künstliche Intelligenz zu ersetzen

Bei der Suche nach einem Arbeitsplatz sind die beiden Top-Belange, die Sie oft in Betracht ziehen,: Gehalt und Aussichten für die Zukunft. Vor kurzem hat das Bureau of Labor Statistics eine Zweijahresprognose der Entwicklung von Hunderten von Karrieren zwischen 2016 und 2026 veröffentlicht. Auf der Grundlage der Prognosen und Schätzungen des durchschnittlichen Jahreseinkommens dieser Arbeitsplätze haben Forscher eine Rangliste der teuersten Berufe in der Zukunft veröffentlicht. Hier werden 21 Stellen mit den höchsten Gehältern in den kommenden Jahrzehnten erwartet. 21. Landwirte, Viehzüchter, landwirtschaftliche Manager 20 Hauptaufgaben: Planen, verwalten, betreiben Sie den Betrieb, Gewächshaus, Aquakultur, Baumschule, Wald oder andere landwirtschaftliche Anlagen. Anzahl der offenen Stellen im Jahr 2026: 68.700. Durchschnittliches Einkommen im Jahr 2016: 66.360 USD. Voraussetzungen: Abitur oder gleichwertig. Computersystem-Analysator Hau...