Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Adding a PHP build option, rotating an image based on camera data, and a new look at thumbnails in PHP

A real pleasure to do a bit of image manipulation in PHP, and to install an extra module onto our PHP web server. Not common tasks, but ones we have to do occasionally.

Summaries ...

Installing the exif module onto my existing PHP. Note that each build updates config.nice so that adding an option is simply a question of running that script with the extra option selected, then doing a make:

  cd php-5.{version}
  ./config.nice --enable-exif
  make


The (as the administrator) do the install. As this was a live (running) server, but one on which a few seconds of downtime in the middle of the night wouldn't be an issue, I simply stopped httpd, installed the new PHP, and restarted. And, yes, I tested it too ;-)

  su -
  cd /home/graham/packages/php-5.{version}
  /etc/init.d/apachectl stop
  make install
  /etc/init.d/apachectl start
  exit


Purpose of the upgrade - to allow my PHP scripts to examine image file headers to see if they needed rotation. I've posted an updated thumbnail generator that does this - the main code is just a few lines

  $w_required = 300;
  $h_required = $w_required * 3 / 4;
  $image = imagecreatefromjpeg($_GET[img]);
  $image = correctImageOrientation($_GET[img],$image);
  $res = correctImageSize($image,$w_required,$h_required);
  header("content-type: image/jpeg");
  imagejpeg ($res);


with all the work being done in the correctImageSize and correctImageOrientation functions (both of which I have included in the source and both of which are commented to help guide the newcomer (we're a training company, after all!)

A separate PHP script has been used to produce my thumbnail library - simply looping through all the images in a folder - the PHP code in there is just:

  $img_table = "";
  $dh = opendir(".");
  while (false !== ($entry = readdir($dh))) {
    if (! preg_match('/(jpg|JPG)$/',$entry)) continue;
    $img_table .= "<a href=$entry target=fullsize><img src=thumbnew.php?img=$entry border=0 /></a>  ";
  }


Complete source [here]; try it out on the rail partnership web site [here].
(written 2015-02-22)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
H114 - Sourcing, installing and configuring PHP
  [192] Current MySQL and PHP paths and upgrades - (2005-01-28)
  [316] Development Environments - (2005-05-19)
  [481] PHP upgrade - traps to watch - (2005-10-31)
  [934] Clustering, load balancing, mod_rewrite and mod_proxy - (2006-11-21)
  [1667] Checking server performance for PHP generated pages - (2008-06-06)
  [1688] cannot restore segment prot after reloc message - PHP / httpd - (2008-06-26)
  [1731] Apache httpd, MySQL, PHP - installation procedure - (2008-08-01)
  [1768] What is built in to this httpd and PHP? - (2008-08-23)
  [1936] Quick Summary - PHP installation - (2008-12-12)
  [2317] How to make a Risotto (PHP build style) - (2009-08-02)
  [2433] Controlling, supressing, enabling PHP error messages - (2009-10-02)
  [2589] Your PHP code does not work? Here is where to start looking. - (2010-01-18)
  [2646] Compile but do not run PHP - syntax check only - (2010-02-22)
  [3132] Virtual Hosting with Apache http server - an overall scheme, and avoiding common pitfalls - (2011-01-14)
  [3635] Parse error: parse error, unexpected T_STRING on brand new web site - why? - (2012-03-03)
  [3955] Building up from a small PHP setup to an enterprise one - (2012-12-16)
  [4319] PHP - some quick fixes if scripts have issues, and how to use our support - (2014-11-19)

A602 - Web Application Deployment - Apache httpd - Sourcing, Installation, Testing
  [523] Apache httpd release 2.2 - (2005-12-10)
  [526] Apache httpd - serving web documents from different directories - (2005-12-12)
  [550] 2006 - Making business a pleasure - (2006-01-01)
  [660] Stopping and restarting Apache httpd cleanly - (2006-03-29)
  [907] Browser -> httpd -> Tomcat -> MySQL. Restarting. - (2006-10-28)
  [982] Notes from the white board - (2006-12-14)
  [1095] Apache httpd , browser, MySQL and MySQL client downloads - (2007-02-28)
  [1292] DHCP automatic IP address v Static IP - (2007-08-06)
  [1449] Upgrade Mac OSX to Leopard, Web Server Apache httpd config lost - (2007-11-29)
  [1455] Connecting to MySQL 5 from PHP on Mac OSX Leopard - (2007-12-03)
  [1707] Configuring Apache httpd - (2008-07-12)
  [1945] Summary - Apache httpd build on Linux - (2008-12-14)
  [2080] Using ApacheBench and jconsole to test and monitor Tomcat - (2009-03-14)
  [2096] Where is my new Apache httpd installed - (2009-03-22)
  [2184] Choosing the right version of Java and Tomcat - (2009-05-16)
  [2520] Global and Enable - two misused words! - (2009-11-30)
  [3426] Automed web site testing scripted in Ruby using watir-webdriver - (2011-09-09)

H309 - PHP - Maps, Graphics and Geographics
  [320] Ordnance Survey - using a 'Get a map' - (2005-05-22)
  [563] Merging pictures using PHP and GD - (2006-01-13)
  [665] PHP Image viewing application - (2006-04-01)
  [937] Display an image from a MySQL database in a web page via PHP - (2006-11-22)
  [1104] Drawing dynamic graphs in PHP - (2007-03-09)
  [1194] Drawing hands on a clock face - PHP - (2007-05-19)
  [1389] Controlling and labelling Google maps via PHP - (2007-10-13)
  [1390] Converting from postal address to latitude / longitude - (2007-10-13)
  [1391] Ordnance Survey Grid Reference to Latitude / Longitude - (2007-10-14)
  [1628] Gant charts - drawing them with a PHP script - (2008-05-03)
  [1724] addslashes v mysql_real_escape_string in PHP - (2008-07-27)
  [1734] All around the world? - (2008-08-03)
  [1752] Dynamic maps / geographics in PHP - (2008-08-13)
  [1756] Ever had One of THOSE mornings? - (2008-08-16)
  [1923] Making it all worthwhile - (2008-12-04)
  [1956] Images for Christmas - (2008-12-21)
  [2343] World Flags in your PHP pages - (2009-08-10)
  [2361] Geocoding - converting address to latitude / Longitude with PHP via Google - (2009-08-14)
  [2390] Dynamic / changing images on your web page - (2009-09-01)
  [2583] Reducing image size on digital photos - PHP - (2010-01-17)
  [2675] Redirecting to your main domain for correct security keys - (2010-03-13)
  [2729] Uploading a document or image to its own URL via a browser - (2010-04-18)
  [2939] Protecting your images from use out of context - (2010-08-29)
  [3027] Server logs - drawing a graph of gathered data - (2010-11-03)
  [3133] An image from a website that occasionally comes out as hyroglyphics - (2011-01-14)
  [3197] Finding and diverting image requests from rogue domains - (2011-03-08)
  [3211] Computer Graphics in PHP - World (incoming data) to Pixel (screen) conversion - (2011-03-24)
  [3447] Needle in a haystack - finding the web server overload - (2011-09-18)
  [3536] UK Mapping Data - and more to come - under government Open Data measures - (2011-12-03)
  [3584] QR codes - graphics images that provide quick phone links - (2012-01-18)
  [3734] QR codes with marketing logos embedded - (2012-05-16)
  [3817] Fpdf - generating .pdf documents easily from your PHP program - (2012-07-24)
  [4178] Where are you? How to write a geosensitive application - (2013-09-18)
  [4365] The changing face of Christmas - (2014-12-26)
  [4655] Image indexer / thumbnail display scripts in PHP - (2016-02-25)


Back to
Accessing a MySQL database from Python with mysql.connector
Previous and next
or
Horse's mouth home
Forward to
Loving programming in Python - and ready to teach YOU how
Some other Articles
Reading command line parameters in Python
A first graph with Matplotlib in Python
Json is the new marshall, pickle and cPickle / Python
Loving programming in Python - and ready to teach YOU how
Adding a PHP build option, rotating an image based on camera data, and a new look at thumbnails in PHP
Accessing a MySQL database from Python with mysql.connector
Images of our rail promotion campaign
Public training courses - upcoming dates
Different views of a Welsh Valley - but headed home
Java web application for teaching - now with sessions and clustering / load balancing demonstrations
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2021: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4437_Add ... n-PHP.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb