Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Lua, etc
 
Easy conversion - image formats, currencies and distances

If you're converting between distances (inches, feet, metres, centimetres, metres, furlongs or perches), between currecies (dollars, euros, pounds, roubles, lira) or between graphic file formats (.jpg, .png, .gif, .xbm, .tiff), chances are you'll have any one of a large number of different inputs to change to any one of a large number of different outputs. With - for example - 10 currencies, you'll have 100 (one hundred) possible conversions - and the code will get much bigger and less practical with each new currency added.

The solution is to choose an intermediate standard - for example, to convert the incoming currency to the Euro, then from the Euro to the target currency. That reduces your 100 down to 20 conversions .... and if you had 20 currencies, it would reduce 400 down to 40.

I've got an illustrated example of this techinque on our PHP Techniques Workshop - source code here and the code may be run here. It's also in use on our hotel currency page if guests with to pay in Euros or Dollars - that's based on a more general exchange rate convertor here.

Please consider with this technique that you need to be careful to avoid a loss of precision / information at the intermediate stage.

If your intermediate graphic file standard was .jpg ... it would be a poor choice. .jpg is a lossy standard which makes some compromises. Similarly, an 8 bit image standard would not be suitable.

If your exchange rate tables include commission or are not mid-rate, once again the double conversion I advocate above would lead to an incorrectly rounded result with some loss of data or accuracy. (The ECB tables we use ARE midrate, so there's not an issue!)
(written 2008-05-21)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
H312 - PHP - Tips and Techniques
  [4621] The power of scripting - (2016-01-12)
  [4426] FileMaker Day to Unix Time conversion - (2015-02-15)
  [4319] PHP - some quick fixes if scripts have issues, and how to use our support - (2014-11-19)
  [4310] Problem ... I want to print a series of numbered forms - (2014-10-05)
  [4074] A comment on comments in PHP - (2013-04-28)
  [2981] How to set up short and meaningfull alternative URLs - (2010-10-02)
  [2478] How did I do THAT? - (2009-10-26)
  [2274] PHP preg functions - examples and comparision - (2009-07-08)
  [2025] Injection Attack if register_globals in on - PHP - (2009-02-04)
  [1983] Keeping PHP code in database and running it - (2009-01-09)
  [1958] PHP - Parse error: syntax error, unexpected $end ... - (2008-12-23)
  [1684] Two PHP include files to make easy web site indexing and navigation - (2008-06-21)
  [1667] Checking server performance for PHP generated pages - (2008-06-06)
  [1270] PHP Standalone - keyboard to screen - (2007-07-18)
  [1010] Dates, times, clickable diarys in PHP - (2006-12-28)
  [917] Syntax checking in PHP - (2006-11-07)
  [789] Hot answers in PHP - (2006-07-02)


Back to
The tourists guide to Linux
Previous and next
or
Horse's mouth home
Forward to
Looking for files with certain characteristics (Linux / Unix)
Some other Articles
How do Google Ads work?
Old Sarum airfield brings back fond memories
ls command - favourite options
Looking for files with certain characteristics (Linux / Unix)
Easy conversion - image formats, currencies and distances
The tourists guide to Linux
Exchange Rates - PHP with your prices in your users currency
Using cookies and sessions to connect different URLs - PHP
Seeing how others do it - PHP training
Using a utility method to construct objects of different types - Python
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., 2019: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/1649_Eas ... ances.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat