WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Simple way of scaling any image to fit either given width or height.
Categories : PHP, Graphics, Arrays Update Picture
Andy Krause
Date : Dec 05th 2000
Grade : 1 of 5 (graded 2 times)
Viewed : 5915
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Andy Krause
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

If you are fed up of always manually manipulating the layout with images, try this code:

<?
$width=300; //size in pixel
$height=300; //size in pixel
$image="sample.jpg";

<img src="<? echo $image ?>" border="0" <? check_image($image) ?> >

?>


Include this function in your scripts:

<?
function check_image($image,$cfgMaxImgWidth,$cfgMaxImgHeight)
        {
        global $strNewImageSize,$cfgMaxImgWidth,$cfgMaxImgHeight;
        $imageAttributes=$strNewImageSize="";
        $imageAttributes=GetImageSize($image);
        if($imageAttributes[0]>$cfgMaxImgWidth)
                {
                $factor=$imageAttributes[0]/$cfgMaxImgWidth;
                $newImgWidth=$cfgMaxImgWidth;
                $newImgHeight=round($imageAttributes[1]/$factor);
                $strNewImageSize="width=$newImgWidth height=$newImgHeight";
                }
        elseif($imageAttributes[1]>$cfgMaxImgHeight)
                {
                $factor=$imageAttributes[1]/$cfgMaxImgHeight;        
                $newImgHeight=$cfgMaxImgHeight;
                $newImgWidth=round($imageAttributes[0]/$factor);
                $strNewImageSize="width=$newImgWidth height=$newImgHeight";
                }
        echo $strNewImageSize;
        }
?>

What happens: the given image will be scaled either if it is too wide or too high or both, down
to the set values. It will be nicely scaled by maintaining the aspect ratio.

Enjoy

n-dee



How to display any array in several rows and columns of a table. Not just in one column or in alternate rows. This example shows a nice color table generated with PHP, but can be used with any array values(e.g. Database)
Categories : Arrays, PHP, Miscellaneous, Beginner Guides, Graphics
HTML_Graphs uses PHP to provide a consistent interface for creating HTML based charts. The user of the class sets up arrays that are passed to html_graph() which then takes care of all the messy HTML layout.
Categories : Graphics, Arrays, PHP, PHP Classes, Charts and Graphs
Simple PHP Bar Graph using GD library
Categories : PHP, GD image library, Graphics, Arrays
This script will read all images from a folder and read the files into an array. It uses rand() to get a random number. It will display a random image from the image folder given.
Categories : PHP, Arrays, Graphics, Filesystem
PHP Email image generator - hide your email from bots - using the GD Library
Categories : PHP, Graphics, GD image library, Beginner Guides
PHP Array to Javascript Object
Categories : PHP, Arrays, Java Script
Line graphics generation library written in PHP + GD library (spanish comments)
Categories : PHP, Graphics, GD image library
This functions makes it easy to use session-variables known from ASP. With one Cookie the array "session" will save and restore from a db-record. In this version MySQL is used but it's should very easy to change
Categories : PHP, Arrays, Cookies, MySQL, Databases
Parse string to find sub-string between two arbitrary strings
Categories : PHP, Strings, HTML and PHP, Arrays
Diffusion-Limited Aggregation visualization
Categories : PHP, Graphics, Algorithms, Math.
A class to put get and post variables in hidden form elements. Works on scalars, normal arrays, associative arrays.
Categories : Algorithms, Variables, Arrays, PHP, PHP Classes
Can the word DO be used in arrays?
Categories : Arrays, PHP, Strings
This is a simple photo gallery that reads the image files from multiple directories, and generates a web page styled with CSS1. It opens single auto window to view and print a given image.
Categories : Graphics, Filesystem, PHP, Complete Programs
This program implements hot link prevention in php. It is useful for webmasters who do not have access to the server at a level where they can control hot linking can still supply some type of hot link prevention for thier site by using php.
Categories : PHP, Filesystem, Graphics, Content Management
The simple counter with use MySql and gd.
Categories : MySQL, HTTP, Graphics, PHP, Databases