Niouzes

< Mai 2018 >
Lu Ma Me Je Ve Sa Di
  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      

Citation

Attention

The documentation is incomplete. The Vae Soli! team works hard to make it as exhaustive as possible with tons of useful examples and easy to understand explanations.

On top of that, we have decided to use our own tool to generate the documentation you read. This also takes time to fine-tune. Our goal is have better documentation, easier to read, easier to use, completely integrated with our site.

Even though NOT finalized, you can now link back to our documentation pages as we have decided once and for all about the structure of our documents and where they all reside on our server.

Thank you very much
The Vae Soli! team.

2018-05-20 à 07:15:18

Table Of Contents

  1. FOUNDATION (functions) (01/04/2015)
  2. LSAction (class) (01/04/2015)
  3. LSAddress (class) (01/04/2015)
  4. LSAdministrativeArea (class) (01/04/2015)
  5. LSApplication (class) (14/10/2013)
  6. LSArray (class) (14/10/2013)
  7. LSArticle (class) (18/02/2014)
  8. LSAssertion (class) (14/10/2013)
  9. LSAudience (class) (18/02/2014)
  10. AUTOLOAD (function) (21/04/2014)
  11. LSAutoReference (class) (14/10/2013)
  12. LSBag (class) (14/10/2013)
  13. LSBBCodes (class) (10/06/2014)
  14. LSBrowser (class) (14/10/2013)
  15. LSCache (class) (14/10/2013)
  16. LSCalculator (class) (14/10/2013)
  17. LSCalendar (class) (14/10/2013)
  18. LSCameraSnapshot (class) (14/10/2013)
  19. LSCitation (class) (14/10/2013)
  20. LSClass (class) (14/10/2013)
  21. LSCode (class) ()
  22. Colors (functions) (20/05/2018)
  23. LSContactForm (class) (14/10/2013)
  24. LSContainer (class) (14/10/2013)
  25. LSContents (class) (14/10/2013)
  26. LSContentsAccounts (class) (14/10/2013)
  27. LSContentsArticles (class) (14/10/2013)
  28. LSContentsAtomicClock (class) (14/10/2013)
  29. LSContentsBusinessCoordinates (class) (14/10/2013)
  30. LSContentsBusinessOff (class) (14/10/2013)
  31. LSContentsBusinessOpeningHours (class) (14/10/2013)
  32. LSContentsBreadcrumb (class) (14/10/2013)
  33. LSContentsCalendar (class) (14/10/2013)
  34. LSContentsCatalogue (class) (14/10/2013)
  35. LSContentsCharter (class) (18/02/2014)
  36. LSContentsCitation (class) (14/10/2013)
  37. LSContentsClock (class) (14/10/2013)
  38. LSContentsComments (class) (14/10/2013)
  39. LSContentsCookieUsage (class) (14/10/2013)
  40. LSContentsCountdown (class) (14/10/2013)
  41. LSContentsDatetime (class) (14/10/2013)
  42. LSContentsHeartbeat (class) (14/10/2013)
  43. LSContentsIFrame (class) (14/10/2013)
  44. LSContentsImageGallery (class) (14/10/2013)
  45. LSContentsLanguageSwitchers (class) (14/10/2013)
  46. LSContentsLegal (class) (18/02/2014)
  47. LSContentsMicronews (class) (14/10/2013)
  48. LSContentsMyAccount (class) (14/10/2013)
  49. LSContentsPaymentOptions (class) (14/10/2013)
  50. LSContentsPinboard (class) (14/10/2013)
  51. LSContentsRememberPassword (class) (14/10/2013)
  52. LSContentsRSS (class) (14/10/2013)
  53. LSContentsSiteManager (class) (14/10/2013)
  54. LSContentsSitemap (class) (14/10/2013)
  55. LSContentsShare (class) (14/10/2013)
  56. LSContentsStopwatch (class) (14/10/2013)
  57. LSContentsTagCloud (class) (14/10/2013)
  58. LSContentsTodosOnPage (class) (14/10/2013)
  59. LSContentsW3C (class) (14/10/2013)
  60. LSContentsWeather (class) (14/10/2013)
  61. LSControl (class) (14/10/2013)
  62. LSCreativeWork (class) (18/02/2014)
  63. LSCursor (class) (09/03/2015)
  64. LSCustomer (class) (14/10/2013)
  65. LSDataEnvironment (class) (14/10/2013)
  66. Dates (functions) (01/04/2015)
  67. LSDate (class) (14/10/2013)
  68. LSDictionary (class) (14/10/2013)
  69. LSDom, LSDomNode and LSXPath (class) (30/04/2014)
  70. LSErrors and LSError (classes) (14/10/2013)
  71. LSException (class) (16/10/2013)
  72. LSExplorer (class) (14/10/2013)
  73. LSFieldset (class) (14/10/2013)
  74. LSFile (class) (14/10/2013)
  75. LSFileProperties (class) (14/10/2013)
  76. Files (functions) (01/04/2015)
  77. Finance (functions) (01/04/2015)
  78. LSFootnotes (class) (22/02/2014)
  79. LSForm (class) (09/06/2014)
  80. LSFunction (class) (14/10/2013)
  81. LSGeorama (class) (24/10/2013)
  82. LSGeoramaVar (class) (24/10/2013)
  83. LSGlossary (class) (09/03/2015)
  84. LSGroup (class) (14/10/2013)
  85. HTML (functions) (01/04/2015)
  86. LSHttp (class) (14/10/2013)
  87. HTTP (functions) (01/04/2015)
  88. LSImageGallery (class) (14/10/2013)
  89. Images (functions) (01/04/2015)
  90. LSInput (class) (26/04/2014)
  91. IP (functions) (01/04/2015)
  92. LSIslandAbstract (14/10/2013)
  93. LSIslandFormAbstract (class) (14/10/2013)
  94. LSLabel (class) (14/10/2013)
  95. LSLanguageSwitchers (class) (14/10/2013)
  96. LSLatin (class) (14/10/2013)
  97. LSLegalPerson (class) (14/10/2013)
  98. LSLinkedList (class) (14/10/2013)
  99. LSList (class) (14/10/2013)
  100. Mails (functions) (01/04/2015)
  101. LSMap (class) (14/10/2013)
  102. Math (functions) (01/04/2015)
  103. LSMicronews (class) (18/02/2014)
  104. Miscellaneous (functions) (01/04/2015)
  105. LSModuleAbstract (class) (14/10/2013)
  106. LSNaturalPerson (class) (14/10/2013)
  107. LSNewsArticle (class) (18/02/2014)
  108. LSNote (class) (14/10/2013)
  109. LSMotherNature (class) (16/10/2013)
  110. LSPage (class) (18/02/2014)
  111. LSParameter (class) (14/10/2013)
  112. LSPaymentOptions (class) (14/10/2013)
  113. LSPeopleAudience (class) (18/02/2014)
  114. LSPerson (class) (14/10/2013)
  115. LSPlace (class) (18/02/2014)
  116. LSProperty (class) (14/10/2013)
  117. LSPublication (class) (14/10/2013)
  118. LSRequirement (class) (14/10/2013)
  119. LSReturn (class) (24/10/2013)
  120. LSRisk (class) (14/10/2013)
  121. LSSentanaiAbstract (14/10/2013)
  122. LSServiceMessage (class) (14/10/2013)
  123. LSSession (class) (14/10/2013)
  124. LSSiteManager (class) (14/10/2013)
  125. LSSitemap (class) (14/10/2013)
  126. LSSockets (class) (14/10/2013)
  127. LSSoftwareApplication (class) (18/02/2014)
  128. LSSource (class) (14/10/2013)
  129. Strings (functions) (31/07/2016)
  130. LSSupplier (class) (14/10/2013)
  131. System (functions) (01/04/2015)
  132. LSTag (class) (21/04/2014)
  133. LSTagCloud (class) (14/10/2013)
  134. LSTechArticle (class) (18/02/2014)
  135. LSThing (class) (18/02/2014)
  136. LSTimeline (class) (14/10/2013)
  137. LSTimer (class) (16/10/2013)
  138. LSTracer (class) (09/03/2015)
  139. LSUnitTesting (class) (14/10/2013)
  140. URL (functions) (01/04/2015)
  141. LSUser (class) (09/03/2015)
  142. LSUserMgr (class) (14/10/2013)
  143. LSVaesoli (class) (09/06/2014)
  144. LSVersion (class) (14/10/2013)
  145. LSWebSite (class) (14/10/2013)
  146. LSWidget (class) (14/10/2013)
  147. LSWireTransferForm (class) (14/10/2013)
  148. LSXMLSitemap (class) (14/10/2013)
  149. XML (functions) (01/04/2015)

LSImages.functions.php

Generated by The Vae Soli! Documentor: Guide v. 1.3.0018 on 01-04-2015 16:19:53 (DD-MM-YYYY HH:mm:SS). This documentation is built with Vae Soli! functions and classes!

The download page of Vae Soli! contains all sources of the framework.

Additional samples are available on the samples page of Vae Soli!.

File Properties

C:\websites\vaesoli.org\www\httpdocs/vaesoli/include/LSImages.functions.phpC:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSImages.functions.phpapplication/force-downloadC:\websites\vaesoli.org\www\httpdocs\vaesoli\include87614 bytes03/08/2013 23:27:5226/09/2013 16:46:5603/08/2013 23:27:52

Compliance

Assertions count: 0

Assertions successful: 0

Assertion failures: 0

Early Warning

LSImages.functions.php exceeds 51200 bytes. We suggest this file got broken down in smaller chunks!

LSImages.functions.php contains 1952 lines of code, which exceeds the suggested limit of 1024 lines. We suggest this file got broken down in smaller chunks!

0001 ... <?php
0002 ... /**************************************************************************/
0003 ... /** {{{*fheader
0004 ...     {*file                  LSImages.functions.php *}
0005 ...     {*purpose               Image oriented functions *}
0006 ...     {*author                 *}
0007 ...     {*company               Lato Sensu Management[br]
0008 ...                             Rue Bois des Mazuis, 47[br]
0009 ...                             5070 Vitrival[br]
0010 ...                             Belgium (BE)[br]
0011 ...                             http://www.latosensu.be[br]
0012 ...                             Vae Soli! : http://www.vaesoli.org *}
0013 ...     {*cdate                 15/04/2008 - 16:53 *}
0014 ...     {*mdate                 auto *}
0015 ...     {*use                   LSColors.functions.php *}
0016 ...     {*license               [url]http://creativecommons.org/licenses/by-sa/2.0/be/[/url][br]
0017 ... 
0018 ...                             To obtain detailed information about the license
0019 ...                             terms, please head to the full license text
0020 ...                             available in the [file]LSCopyright.php[/file] file *}
0021 ... 
0022 ...     ------------------------------------------------------------------------
0023 ...     Changes History:
0024 ...     ------------------------------------------------------------------------
0025 ... 
0026 ...     {*chist
0027 ...         {*mdate 06/05/2008 *}
0028 ...         {*v 1.1.0515 *}
0029 ...         {*desc              1)  All comments before this release have been
0030 ...                                 eliminated (for tracking purposes, please
0031 ...                                 head to the Vae Soli! archive
0032 ...                                 (vaesoli-1.1.0501.zip)
0033 ...         *}
0034 ...     *}
0035 ... 
0036 ...     {*chist
0037 ...         {*mdate 08/01/2009 *}
0038 ...         {*v 2.0.0000 *}
0039 ...         {*desc              1)  Shrinking Vae Soli! features to concentrate
0040 ...                                 on the fundamentals (many features have been
0041 ...                                 put on hold: they will be integrated one by
0042 ...                                 one when their code will be entirey finished
0043 ...                                 instead of having them not doig what they're
0044 ...                                 supposed to do)
0045 ...         *}
0046 ...     *}
0047 ... 
0048 ...     {*chist
0049 ...         {*mdate 29/04/2009 *}
0050 ...         {*v 2.0.0009 *}
0051 ...         {*desc              1)  IMG_Flip() : new function
0052 ...         *}
0053 ...     *}
0054 ... 
0055 ...     {*chist
0056 ...         {*mdate 01/05/2009 *}
0057 ...         {*v 2.1.0000 *}
0058 ...         {*desc              1)  IMG_Redimension() : new function
0059 ...                             2)  IMG_Scale() : alias of IMG_Resize()
0060 ...         *}
0061 ...     *}
0062 ...     *}}} */
0063 ... /**************************************************************************/
0064 ... if ( ! defined( 'LSImages' ) )
0065 ... {
0066 ...     /* {*define (LSImages)  Define "LS" Images (Pat Was Here) *} */
0067 ...     define( 'LSImages','PWH' );
0068 ... }   /* if ( ! defined( 'LSImages' ) ) */
0069 ... 
0070 ... if ( ! defined( 'VAESOLI_PATH' ) )                                  /* If the path is not defined yet */
0071 ... {
0072 ...     /* {*define (VAESOLI_PATH)  Define the path where Vae Soli! is installed *} */
0073 ...     define( 'VAESOLI_PATH',__DIR__ );
0074 ... }   /* if ( ! defined( 'VAESOLI_PATH' ) ) */
0075 ... 
0076 ... if ( ! defined( 'VAESOLI_PLUGINS' ) )                               /* If the path is not defined yet */
0077 ... {
0078 ...     /* {*define (VAESOLI_PLUGINS)  Define the path where plugins are located *} */
0079 ...     define( 'VAESOLI_PLUGINS',VAESOLI_PATH . '/../plugins' );
0080 ... }   /* if ( ! defined( 'VAESOLI_PLUGINS' ) ) */
0081 ... 
0082 ... require_once( VAESOLI_PATH . '/LSColors.functions.php'  );          /* Color functions of the framework */
0083 ... 
0084 ... //function screen(&$image) {
0085 ... //    $imagex = imagesx($image);
0086 ... //    $imagey = imagesy($image);
0087 ... //    GLOBAL $black;
0088 ... //
0089 ... //    for($x = 1; $x <= $imagex; $x += 2) {
0090 ... //        imageline($image, $x, 0, $x, $imagey, $black);
0091 ... //    }
0092 ... //
0093 ... //    for($y = 1; $y <= $imagey; $y += 2) {
0094 ... //        imageline($image, 0, $y, $imagex, $y, $black);
0095 ... //    }
0096 ... //}
0097 ... 
0098 ... 
0099 ... function RGBtoHSB ($new_r,$new_g,$new_b)
0100 ... {
0101 ...    $arrayHSB = array($new_r,$new_g,$new_b);
0102 ...    $h = 0.0 ;
0103 ...    $minRGB = min($new_r,$new_g,$new_b);
0104 ...    $maxRGB = max($new_r,$new_g,$new_b);
0105 ... 
0106 ...    $delta = ($maxRGB - $minRGB);
0107 ...    $bright = $maxRGB;
0108 ... 
0109 ...     if ($maxRGB != 0.0)
0110 ...     {
0111 ...         $s = $delta / $maxRGB;
0112 ...     }
0113 ...     else
0114 ...     {
0115 ...         $s = 0.0;
0116 ...         $h=-1;
0117 ...     }
0118 ... 
0119 ...    if ($s != 0.0){
0120 ...       if ($new_r == $maxRGB) {
0121 ...          $h = ($new_g - $new_b) / $delta;
0122 ...       }
0123 ...       else {
0124 ...          if ($new_g == $maxRGB) {
0125 ...             $h = 2.0 + ($new_b - $new_r) / $delta;
0126 ...          }
0127 ...          else {
0128 ...             if ($new_b == $maxRGB) {
0129 ...                $h = 4.0 + ($new_r - $new_g) / $delta;
0130 ...             }
0131 ...          }
0132 ...       }
0133 ...    }
0134 ...    else {
0135 ...       $h = -1.0;
0136 ...    }
0137 ...    $h = $h * 60.0 ;
0138 ...    if ($h < 0.0) {$h = $h + 360.0;}
0139 ... 
0140 ...    $arrayHSB[0]=$h;
0141 ...    $arrayHSB[1]=$s;
0142 ...    $arrayHSB[2]=$bright;
0143 ... 
0144 ...    return $arrayHSB;
0145 ... }
0146 ... 
0147 ... 
0148 ... 
0149 ... function HSBtoRGB($new_hue,$new_saturation,$new_bright){
0150 ...    $arrayRGB= array($new_hue,$new_saturation,$new_bright);
0151 ...    if($new_saturation == 0.0) {
0152 ...       $r=$new_bright;
0153 ...       $g=$new_bright;
0154 ...       $b=$new_bright;
0155 ...    }
0156 ... 
0157 ...    $new_hue = $new_hue/60.0;
0158 ...    $m = floor($new_hue);
0159 ...    $f = $new_hue - $m;
0160 ...    $p = $new_bright * (1.0 - $new_saturation);
0161 ...    $q = $new_bright * (1.0 - $new_saturation * $f);
0162 ...    $t = $new_bright * (1.0 - $new_saturation * (1.0 - $f));
0163 ... 
0164 ... 
0165 ...    switch($m) {
0166 ...       case 0:
0167 ...          $r = $new_bright;
0168 ...          $g = $t;
0169 ...          $b = $p;
0170 ...          break;
0171 ...       case 1:
0172 ...          $r = $q;
0173 ...          $g = $new_bright;
0174 ...          $b = $p;
0175 ...          break;
0176 ...       case 2:
0177 ...          $r = $p;
0178 ...          $g = $new_bright;
0179 ...          $b = $t;
0180 ...          break;
0181 ...       case 3:
0182 ...          $r = $p;
0183 ...          $g = $q;
0184 ...          $b = $new_bright;
0185 ...          break;
0186 ...       case 4:
0187 ...          $r = $t;
0188 ...          $r = $p;
0189 ...          $r = $new_bright;
0190 ...          break;
0191 ...       default:      // case 5:
0192 ...          $r= $new_bright;
0193 ...          $g = $p;
0194 ...          $b = $q;
0195 ...    }
0196 ... 
0197 ...    $arrayRGB[0]=$r;
0198 ...    $arrayRGB[1]=$g;
0199 ...    $arrayRGB[2]=$b;
0200 ... 
0201 ...    return $arrayRGB;
0202 ... }
0203 ... 
0204 ... /* ====================================================================== */
0205 ... /** {{*IMG_Brightness( $szImg,$szTarget[,$fBright[,$iQuality]] )=
0206 ... 
0207 ...     Modify image luminosity (brightness)
0208 ... 
0209 ...     {*params
0210 ...         $szImg      (string)        Image to be processed
0211 ...         $szTarget   (string)        Image to be saved
0212 ...         $fBright    (float)         Optional brightness (a value between [c]0[/c]
0213 ...                                     and [c]1[/c]); [c]0.5[/c] by default.
0214 ...         $iQuality   (int)           Optional quality required when saving the
0215 ...                                     image. [c]75[/c] by default.
0216 ...     *}
0217 ... 
0218 ...     {*return
0219 ...         (bool)          [c]true[/c] if image treated and saved successfully;
0220 ...                         [c]false[/c] if not
0221 ...     *}
0222 ... 
0223 ...     {*credits
0224 ...         Octavia Andreea Anghel
0225 ...     *}
0226 ... 
0227 ...     {*doc
0228 ...         [url]http://www.devx.com/webdev/Article/37179/0/page/1[/url]
0229 ...     *}
0230 ... 
0231 ...     {*example
0232 ...         $szSrc  = "c:\\images\\transform\\continent.jpg";
0233 ...         $szDest = "c:\\images\\transform\\continent-dark.jpg";
0234 ... 
0235 ...         if ( ! FIL_Exists( $szDest ) )
0236 ...         {
0237 ...             IMG_Brightness( $szSrc,$szDest,0.2,90 );
0238 ...         }
0239 ...     *}
0240 ... 
0241 ...     {*version
0242 ...         1.0.0005
0243 ...     *}
0244 ... 
0245 ...     {*seealso
0246 ...         IMG_Saturation(), IMG_Hue()
0247 ...     *}
0248 ... 
0249 ...     *}}
0250 ...  */
0251 ... /* ====================================================================== */
0252 ... function IMG_Brightness( $szImg,$szTarget,$fBright = 0.5,$iQuality = 75 )
0253 ... /*---------------------------------------------------------------------*/
0254 ... {
0255 ...     $bRetVal    = false;                                            /* Ready to return a logical false */
0256 ...     $szType     = '';                                               /* Image type ('gif', 'png', 'jpg' ...) */
0257 ...     $img        = OpenImage( $szImg,$szType );                      /* Open image */
0258 ... 
0259 ...     if ( $img )
0260 ...     {
0261 ...         $iWidth = $iHeight = 0; ImageSize( $szImg,$iWidth,$iHeight );/* Obtain image info (width and height are updated ) */
0262 ... 
0263 ...         for($j=0;$j<$iHeight;$j++)
0264 ...         {
0265 ...             for($i=0;$i<$iWidth;$i++)
0266 ...             {
0267 ...                 $rgb = imagecolorat($img, $i, $j);
0268 ... 
0269 ...                  $r = ($rgb >> 16) & 0xFF;
0270 ...                  $g = ($rgb >> 8) & 0xFF;
0271 ...                  $b = $rgb & 0xFF;
0272 ... 
0273 ...                  $getArrayHSB = RGBtoHSB($r,$g,$b);
0274 ... 
0275 ...                  $brightness = 100; //[0.0, 1.0] - darker,[1.0, 10.0] - brightner
0276 ...                  $getArrayHSB[2] = $brightness*$getArrayHSB[2];
0277 ...                  $getArrayHSB[2] = max(0.0,min($getArrayHSB[2],255.0));
0278 ... 
0279 ...                  $getArrayRGB = HSBtoRGB(
0280 ...                     $getArrayHSB[0], $getArrayHSB[1],
0281 ...                     $getArrayHSB[2]);
0282 ... 
0283 ...                  $hsbrgb = imagecolorallocate(
0284 ...                     $img, $getArrayRGB[0], $getArrayRGB[1],
0285 ...                     $getArrayRGB[2]);
0286 ...                  $result = (($rgb & 0xff000000)|($hsbrgb));
0287 ... 
0288 ...                  imagesetpixel($img, $i, $j, $result);
0289 ...             }
0290 ...         }
0291 ... 
0292 ...         switch ( $szExt )                                           /* In function of the file extension */
0293 ...         {
0294 ...             case 'gif' :  $bRetVal = @imagegif( $img,$szTarget );    /* Save the new image to a GIF file */
0295 ...                           break;
0296 ...             case 'png' :  $bRetVal = @imagepng( $img,$szTarget );    /* Save the new image to a PNG file */
0297 ...                           break;
0298 ...             default     : $bRetVal = @imagejpeg( $img,$szTarget,$iQuality );/* Save the new image to a JPG file */
0299 ...         }   /* switch ( $szExt ) */
0300 ... 
0301 ...         imagedestroy( $img );                                        /* Releases all the memory associated with the image */
0302 ... 
0303 ...     }
0304 ... 
0305 ...     return ( $bRetVal );
0306 ... 
0307 ... }   /* End of function IMG_Brightness() */
0308 ... /* ====================================================================== */
0309 ... 
0310 ... /* ====================================================================== */
0311 ... /** {{*IMG_Saturation( $szImg,$szTarget[,$fSat[,$iQuality[,$aRect]]] )=
0312 ... 
0313 ...     Modify the image saturation
0314 ... 
0315 ...     {*params
0316 ...         $szImg      (string)        Image to be processed
0317 ...         $szTarget   (string)        Image to be saved
0318 ...         $fSat       (float)         Optional saturation level (a value between
0319 ...                                     [c]0[/c] and [c]1[/c])[br]
0320 ...                                     0 = no color (only grey levels)[br]
0321 ...                                     1 = full color saturation.
0322 ...         $iQuality   (int)           Optional quality required when saving the
0323 ...                                     image. [c]75[/c] by default.
0324 ...         $aRect      (array)         Optional rectangle. [c]null[/c] by default[br]
0325 ...                                     [c]$aRect[0][/c] = Start x[br]
0326 ...                                     [c]$aRect[1][/c] = Start y[br]
0327 ...                                     [c]$aRect[2][/c] = End x[br]
0328 ...                                     [c]$aRect[3][/c] = End y[br]
0329 ...     *}
0330 ... 
0331 ...     {*return
0332 ...         (bool)          [c]true[/c] if image treated and saved successfully;
0333 ...                         [c]false[/c] if not
0334 ...     *}
0335 ... 
0336 ...     {*credits
0337 ...         Octavia Andreea Anghel
0338 ...     *}
0339 ... 
0340 ...     {*doc
0341 ...         [url]http://www.devx.com/webdev/Article/37179/0/page/1[/url]
0342 ...     *}
0343 ... 
0344 ...     {*example
0345 ...         $szSrc  = "c:\\images\\transform\\continent.jpg";
0346 ...         $szDest = "c:\\images\\transform\\continent-high-saturation.jpg";
0347 ... 
0348 ...         if ( ! FIL_Exists( $szDest ) )
0349 ...         {
0350 ...             IMG_Saturation( $szSrc,$szDest,1.0,95 );
0351 ...         }
0352 ...     *}
0353 ... 
0354 ...     {*version
0355 ...         1.0.0005
0356 ...     *}
0357 ... 
0358 ...     {*seealso
0359 ...         IMG_Brightness(), IMG_Hue()
0360 ...     *}
0361 ... 
0362 ...     *}}
0363 ...  */
0364 ... /* ====================================================================== */
0365 ... function IMG_Saturation( $szImg,$szTarget,$fSat = 1,$iQuality = 75,$aRect = null )
0366 ... /*------------------------------------------------------------------------------*/
0367 ... {
0368 ...     $bRetVal    = false;                                            /* Ready to return a logical false */
0369 ...     $szType     = '';                                               /* Image type ('gif', 'png', 'jpg' ...) */
0370 ...     $img        = OpenImage( $szImg,$szType );                      /* Open image */
0371 ... 
0372 ...     if ( $img )                                                     /* If 'image resource' successfully created */
0373 ...     {
0374 ...         $iQuality   = max( min( $iQuality,100 ),0 );                /* 0 <= JPG quality <= 100 */
0375 ... 
0376 ...         $iWidth = $iHeight = 0; ImageSize( $szImg,$iWidth,$iHeight );/* Obtain image info (width and height are updated ) */
0377 ... 
0378 ...         if ( is_null( $aRect ) )                                    /* If rectangle coordinates NOT passed */
0379 ...         {
0380 ...             $iStartWidth = $iStartHeight = 0;                       /* Use image height and width */
0381 ...             $iEndWidth   = $iWidth; $iEndHeight  = $iHeight;
0382 ...         }   /* if ( is_null( $aRect ) ) */
0383 ...         else   /* Else of ... if ( is_null( $aRect ) ) */
0384 ...         {
0385 ...             $iStartWidth  = $aRect[0];                              /* Start x */
0386 ...             $iStartHeight = $aRect[1];                              /* Start y */
0387 ...             $iEndWidth    = $aRect[2];                              /* End x */
0388 ...             $iEndHeight   = $aRect[3];                              /* End y */
0389 ...         }   /* End of ... Else of ... if ( is_null( $aRect ) ) */
0390 ... 
0391 ...         for( $j = $iStartHeight;$j < $iEndHeight;$j++ )             /* For each row */
0392 ...         {
0393 ...             for( $i = $iStartWidth;$i < $iEndWidth;$i++ )           /* For each column */
0394 ...             {
0395 ...                 $aHSL   = COLOR_rgb2hsl(
0396 ...                             COLOR_int2rgb2(
0397 ...                                imagecolorat( $img,$i,$j )
0398 ...                             )
0399 ...                           );                                        /* Pixel color at position $i,$j (HSL) */
0400 ... 
0401 ...                 $aHSL['s'] = $fSat;                                 /* Set new saturation */
0402 ...                 $aRGB   = COLOR_hsl2rgb( $aHSL );                   /* Transform HSL to RGB */
0403 ... 
0404 ...                 $result = imagecolorallocate( $img           ,       /* Image resource */
0405 ...                                               $aRGB['r']   ,        /* Red component */
0406 ...                                               $aRGB['g']   ,        /* Green component */
0407 ...                                               $aRGB['b'] );         /* Blue component */
0408 ... 
0409 ...                 imagesetpixel( $img,$i,$j,$result );                 /* Set pixel color */
0410 ...             }   /* for( $i=0;$i<$iWidth;$i++ ) */
0411 ...         }   /* for( $j=0;$j<$iHeight;$j++ ) */
0412 ... 
0413 ...         switch ( $szType )                                           /* In function of the file extension */
0414 ...         {
0415 ...             case 'gif' :  $bRetVal = @imagegif( $img,$szTarget );    /* Save the new image to a GIF file */
0416 ...                           break;
0417 ...             case 'png' :  $bRetVal = @imagepng( $img,$szTarget );    /* Save the new image to a PNG file */
0418 ...                           break;
0419 ...             default     : $bRetVal = @imagejpeg( $img,$szTarget,$iQuality );/* Save the new image to a JPG file */
0420 ...         }   /* switch ( $szExt ) */
0421 ... 
0422 ...         imagedestroy( $img );                                        /* Releases all the memory associated with the image */
0423 ...     }   /* if ( $img ) */
0424 ... }   /* End of function IMG_Saturation() */
0425 ... /* ====================================================================== */
0426 ... 
0427 ... /* ====================================================================== */
0428 ... /** {{*IMG_Hue( $szImg,$szTarget[,$iHue[,$iQuality[,$aRect]]] )=
0429 ... 
0430 ...     Modify the image hue
0431 ... 
0432 ...     {*params
0433 ...         $szImg      (string)        Image to be processed
0434 ...         $szTarget   (string)        Image to be saved
0435 ...         $iHue       (int)           Hue variation degree (a value between
0436 ...                                     [c]0[/c] to [c]360[/c]). Default value =
0437 ...                                     [c]30[/c]
0438 ...         $iQuality   (int)           Optional quality required when saving the
0439 ...                                     image. [c]75[/c] by default.
0440 ...         $aRect      (array)         Optional rectangle. [c]null[/c] by default[br]
0441 ...                                     [c]$aRect[0][/c] = Start x[br]
0442 ...                                     [c]$aRect[1][/c] = Start y[br]
0443 ...                                     [c]$aRect[2][/c] = End x[br]
0444 ...                                     [c]$aRect[3][/c] = End y[br]
0445 ...     *}
0446 ... 
0447 ...     {*return
0448 ...         (bool)          [c]true[/c] if image treated and saved successfully;
0449 ...                         [c]false[/c] if not
0450 ...     *}
0451 ... 
0452 ...     {*credits
0453 ...         Octavia Andreea Anghel
0454 ...     *}
0455 ... 
0456 ...     {*doc
0457 ...         [url]http://www.devx.com/webdev/Article/37179/0/page/1[/url]
0458 ...     *}
0459 ... 
0460 ...     {*example
0461 ...         $szSrc  = "c:\\images\\transform\\continent.jpg";
0462 ...         $szDest = "c:\\images\\transform\\continent-85-degree.jpg";
0463 ... 
0464 ...         if ( ! FIL_Exists( $szDest ) )
0465 ...         {
0466 ...             IMG_Hue( $szSrc,$szDest,85,90 );
0467 ...         }
0468 ...     *}
0469 ... 
0470 ...     {*version
0471 ...         1.0.0005
0472 ...     *}
0473 ... 
0474 ...     {*seealso
0475 ...         IMG_Brightness(), IMG_Saturation()
0476 ...     *}
0477 ... 
0478 ...     *}}
0479 ...  */
0480 ... /* ====================================================================== */
0481 ... function IMG_Hue( $szImg,$szTarget,$iHue = 30,$iQuality = 75,$aRect = null )
0482 ... /*------------------------------------------------------------------------*/
0483 ... {
0484 ...     /**
0485 ...      *  @todo   Le Hue doit fonctionner EXACTEMENT commme dans la classe LSColor et
0486 ...      *          dans les fonctions de hue
0487 ...      */
0488 ...     $bRetVal    = false;                                            /* Ready to return a logical false */
0489 ...     $szType     = '';                                               /* Image type ('gif', 'png', 'jpg' ...) */
0490 ...     $img        = OpenImage( $szImg,$szType );                      /* Open image */
0491 ... 
0492 ...     /**
0493 ...      *  @todo   Ici, il faut créer un code commun (IMG_Channel() qui fasse
0494 ...      *          simplement la distinction entre le Red, Green, Blue
0495 ...      */
0496 ...     if ( $img )                                                     /* If 'image resource' successfully created */
0497 ...     {
0498 ...         $iQuality   = max( min( $iQuality,100 ),0 );                /* 0 <= JPG quality <= 100 */
0499 ... 
0500 ...         $iWidth = $iHeight = 0; ImageSize( $szImg,$iWidth,$iHeight );/* Obtain image info (width and height are updated ) */
0501 ... 
0502 ...         if ( is_null( $aRect ) )                                    /* If rectangle coordinates NOT passed */
0503 ...         {
0504 ...             $iStartWidth = $iStartHeight = 0;                       /* Use image height and width */
0505 ...             $iEndWidth   = $iWidth; $iEndHeight  = $iHeight;
0506 ...         }   /* if ( is_null( $aRect ) ) */
0507 ...         else   /* Else of ... if ( is_null( $aRect ) ) */
0508 ...         {
0509 ...             $iStartWidth  = $aRect[0];                              /* Start x */
0510 ...             $iStartHeight = $aRect[1];                              /* Start y */
0511 ...             $iEndWidth    = $aRect[2];                              /* End x */
0512 ...             $iEndHeight   = $aRect[3];                              /* End x */
0513 ...         }   /* End of ... Else of ... if ( is_null( $aRect ) ) */
0514 ... 
0515 ...         for( $j = $iStartHeight;$j < $iEndHeight;$j++ )             /* For each row */
0516 ...         {
0517 ...             for( $i = $iStartWidth;$i < $iEndWidth;$i++ )           /* For each column */
0518 ...             {
0519 ...                 $aHSV       = COLOR_rgb2hsv(
0520 ...                                     COLOR_int2rgb2(
0521 ...                                         imagecolorat( $img,$i,$j )
0522 ...                                     )
0523 ...                               );                                    /* Pixel color at position $i,$j (HSV) */
0524 ... 
0525 ...                 /* New hue is a modification of current hue : degrees on chromatic circle */
0526 ...                 $aHSV['h'] = ( ( ( $aHSV['h'] * 360 ) + $iHue ) % 360 / 360 );
0527 ...                 $aRGB   = COLOR_hsv2rgb( $aHSV );                   /* Transform HSV to RGB */
0528 ... 
0529 ...                 $result = imagecolorallocate( $img         ,        /* Image resource */
0530 ...                                               $aRGB['r']   ,        /* Red component */
0531 ...                                               $aRGB['g']   ,        /* Green component */
0532 ...                                               $aRGB['b'] );         /* Blue component */
0533 ... 
0534 ...                 imagesetpixel( $img,$i,$j,$result );                /* Set pixel color */
0535 ...             }   /* for( $i=0;$i<$iWidth;$i++ ) */
0536 ...         }   /* for( $j=0;$j<$iHeight;$j++ ) */
0537 ... 
0538 ...         switch ( $szType )                                          /* In function of the file extension */
0539 ...         {
0540 ...             case 'gif' :  $bRetVal = @imagegif( $img,$szTarget );   /* Save the new image to a GIF file */
0541 ...                           break;
0542 ...             case 'png' :  $bRetVal = @imagepng( $img,$szTarget );   /* Save the new image to a PNG file */
0543 ...                           break;
0544 ...             default     : $bRetVal = @imagejpeg( $img,$szTarget,$iQuality );/* Save the new image to a JPG file */
0545 ...         }   /* switch ( $szExt ) */
0546 ... 
0547 ...         imagedestroy( $img );                                       /* Releases all the memory associated with the image */
0548 ...     }   /* if ( $img ) */
0549 ... }   /* End of function IMG_Hue() */
0550 ... /* ====================================================================== */
0551 ... 
0552 ...     /* ====================================================================== */
0553 ...     /**
0554 ...      *  Transforme une image en nuances de gris
0555 ...      *  @author     Octavia Andreea Anghel
0556 ...      *  @link       http://www.devx.com/webdev/Article/37179/0/page/1
0557 ...      *  @since      version 1.0.0005
0558 ...      *  @param      string      $szImg      Image à traiter
0559 ...      *  @param      string      $szTarget   Image résultat
0560 ...      *  @param      int         $iQuality   Qualité de l'image à sauver (JPG)
0561 ...      *  @param      array       $aRect      Coordonnées de traitement faites
0562 ...      *                                      de deux points start: (x,y)
0563 ...      *                                                     end  : (x',y')
0564 ...      *                                      array( 0,0,100,200 )
0565 ...      *  @return     bool                    vrai (true) si l'image a été
0566 ...      *                                      transformée; faux (false) dans le
0567 ...      *                                      cas contraire.
0568 ...      */
0569 ...     /* ====================================================================== */
0570 ...     function IMG_GrayScale( $szImg,$szTarget,$iQuality = 75,$aRect = null )
0571 ...     /*-------------------------------------------------------------------*/
0572 ...     {
0573 ...         $bRetVal    = false;                                            /* Ready to return a logical false */
0574 ...         $szType     = '';                                               /* Image type ('gif', 'png', 'jpg' ...) */
0575 ...         $img        = OpenImage( $szImg,$szType );                      /* Open image */
0576 ... 
0577 ...         /**
0578 ...          *  @todo   Ici, il faut créer un code commun (IMG_Channel() qui fasse
0579 ...          *          simplement la distinction entre le Red, Green, Blue
0580 ...          */
0581 ...         if ( $img )                                                     /* If 'image resource' successfully created */
0582 ...         {
0583 ...             $iQuality   = max( min( $iQuality,100 ),0 );                /* 0 <= JPG quality <= 100 */
0584 ... 
0585 ...             $iWidth = $iHeight = 0; ImageSize( $szImg,$iWidth,$iHeight );/* Obtain image info (width and height are updated ) */
0586 ... 
0587 ...             if ( is_null( $aRect ) )                                    /* If rectangle coordinates NOT passed */
0588 ...             {
0589 ...                 $iStartWidth = $iStartHeight = 0;                       /* Use image height and width */
0590 ...                 $iEndWidth   = $iWidth; $iEndHeight  = $iHeight;
0591 ...             }   /* if ( is_null( $aRect ) ) */
0592 ...             else   /* Else of ... if ( is_null( $aRect ) ) */
0593 ...             {
0594 ...                 $iStartWidth  = $aRect[0];                              /* Start x */
0595 ...                 $iStartHeight = $aRect[1];                              /* Start y */
0596 ...                 $iEndWidth    = $aRect[2];                              /* End x */
0597 ...                 $iEndHeight   = $aRect[3];                              /* End x */
0598 ...             }   /* End of ... Else of ... if ( is_null( $aRect ) ) */
0599 ... 
0600 ...             for( $j = $iStartHeight;$j < $iEndHeight;$j++ )             /* For each row */
0601 ...             {
0602 ...                 for( $i = $iStartWidth;$i < $iEndWidth;$i++ )           /* For each column */
0603 ...                 {
0604 ...                     $aRGB   = COLOR_int2rgb2( imagecolorat( $img,$i,$j ) );/* Pixel color at position $i,$j */
0605 ...                     $bw     = ( $aRGB['r'] + $aRGB['g'] + $aRGB['b'] ) / 3; /* Calculate grayscale (average of red, green, blue) */
0606 ...                     $result = ( 0x000000FF << 24 ) |
0607 ...                               ( $bw        << 16 ) |
0608 ...                               ( $bw        << 8  ) |
0609 ...                               $bw;
0610 ... 
0611 ...                     $new_r = ( $result >> 16) & 0xFF;                   /* Create new red value */
0612 ...                     $new_g = ( $result >> 8 ) & 0xFF;                   /* Create new green value */
0613 ...                     $new_b =   $result        & 0xFF;                   /* Create new blue value */
0614 ... 
0615 ...                     $new_color = imagecolorallocate( $img    ,           /* Assign grayscale color */
0616 ...                                                      $new_r ,           /* New red component */
0617 ...                                                      $new_g ,           /* New green component */
0618 ...                                                      $new_b );          /* New blue component */
0619 ...                     imagesetpixel( $img,$i,$j,$new_color );              /* Set pixel color */
0620 ...                 }   /* for( $i=0;$i<$iWidth;$i++ ) */
0621 ...             }   /* for( $j=0;$j<$iHeight;$j++ ) */
0622 ... 
0623 ...             switch ( $szExt )                                           /* In function of the file extension */
0624 ...             {
0625 ...                 case 'gif' :  $bRetVal = @imagegif( $img,$szTarget );    /* Save the new image to a GIF file */
0626 ...                               break;
0627 ...                 case 'png' :  $bRetVal = @imagepng( $img,$szTarget );    /* Save the new image to a PNG file */
0628 ...                               break;
0629 ...                 default     : $bRetVal = @imagejpeg( $img,$szTarget,$iQuality );/* Save the new image to a JPG file */
0630 ...             }   /* switch ( $szExt ) */
0631 ... 
0632 ...             imagedestroy( $img );                                        /* Releases all the memory associated with the image */
0633 ...         }   /* if ( $img ) */
0634 ...     }   /* End of function IMG_GrayScale() */
0635 ...     /* ====================================================================== */
0636 ... 
0637 ... /* ====================================================================== */
0638 ... /** {{*IMG_Negate( $szImg,$szTarget[,$iQuality[,$aRect]] )=
0639 ... 
0640 ...     Invert image (negate)
0641 ... 
0642 ...     {*params
0643 ...         $szImg      (string)        Image to be processed
0644 ...         $szTarget   (string)        Image to be saved
0645 ...         $iQuality   (int)           Optional quality required when saving the
0646 ...                                     image. [c]75[/c] by default (for .jpg images)
0647 ...         $aRect      (array)         Optional rectangle. [c]null[/c] by default[br]
0648 ...                                     [c]$aRect[0][/c] = Start x[br]
0649 ...                                     [c]$aRect[1][/c] = Start y[br]
0650 ...                                     [c]$aRect[2][/c] = End x[br]
0651 ...                                     [c]$aRect[3][/c] = End y[br]
0652 ...     *}
0653 ... 
0654 ...     {*return
0655 ...         (bool)          [c]true[/c] if image treated and saved successfully;
0656 ...                         [c]false[/c] if not
0657 ...     *}
0658 ... 
0659 ...     {*credits
0660 ...         Octavia Andreea Anghel
0661 ...     *}
0662 ... 
0663 ...     {*doc
0664 ...         [url]http://www.devx.com/webdev/Article/37179/0/page/1[/url]
0665 ...     *}
0666 ... 
0667 ...     {*example
0668 ...         $szSrc  = "c:\\images\\transform\\continent.jpg";
0669 ...         $szDest = "c:\\images\\transform\\continent-negate.jpg";
0670 ... 
0671 ...         if ( ! FIL_Exists( $szDest ) )
0672 ...         {
0673 ...             IMG_Negate( $szSrc,$szDest,$iQuality = 75 );
0674 ...         }
0675 ...     *}
0676 ... 
0677 ...     {*alias
0678 ...         IMG_Invert()
0679 ...     *}
0680 ... 
0681 ...     {*version
0682 ...         1.0.0005
0683 ...     *}
0684 ... 
0685 ...     *}}
0686 ...  */
0687 ... /* ====================================================================== */
0688 ... function IMG_Negate( $szImg,$szTarget,$iQuality = 75,$aRect = null )
0689 ... /*----------------------------------------------------------------*/
0690 ... {
0691 ...     $bRetVal    = false;                                            /* Ready to return a logical false */
0692 ...     $szType     = '';                                               /* Image type ('gif', 'png', 'jpg' ...) */
0693 ...     $img        = OpenImage( $szImg,$szType );                      /* Open image */
0694 ... 
0695 ...     if ( $img )                                                     /* If 'image resource' successfully created */
0696 ...     {
0697 ...         $iQuality   = max( min( $iQuality,100 ),0 );                /* 0 <= JPG quality <= 100 */
0698 ... 
0699 ...         $iWidth = $iHeight = 0; ImageSize( $szImg,$iWidth,$iHeight );/* Obtain image info (width and height are updated ) */
0700 ... 
0701 ...         if ( is_null( $aRect ) )                                    /* If rectangle coordinates NOT passed */
0702 ...         {
0703 ...             $iStartWidth = $iStartHeight = 0;                       /* Use image height and width */
0704 ...             $iEndWidth   = $iWidth; $iEndHeight  = $iHeight;
0705 ...         }   /* if ( is_null( $aRect ) ) */
0706 ...         else   /* Else of ... if ( is_null( $aRect ) ) */
0707 ...         {
0708 ...             $iStartWidth  = $aRect[0];                              /* Start x */
0709 ...             $iStartHeight = $aRect[1];                              /* Start y */
0710 ...             $iEndWidth    = $aRect[2];                              /* End x */
0711 ...             $iEndHeight   = $aRect[3];                              /* End x */
0712 ...         }   /* End of ... Else of ... if ( is_null( $aRect ) ) */
0713 ... 
0714 ...         for( $j = $iStartHeight;$j < $iEndHeight;$j++ )             /* For each row */
0715 ...         {
0716 ...             for( $i = $iStartWidth;$i < $iEndWidth;$i++ )           /* For each column */
0717 ...             {
0718 ...                 $rgb = imagecolorat( $img,$i,$j );                   /* Pixel color at that i,j position */
0719 ...                 $result = ( $rgb & 0xff000000 ) +                   /* Invert color */
0720 ...                           ( $rgb & 0xffffff   ) ^
0721 ...                           0xffffff;
0722 ... 
0723 ...                 $new_r = ( $result >> 16) & 0xFF;                   /* New red */
0724 ...                 $new_g = ( $result >> 8 ) & 0xFF;                   /* New green */
0725 ...                 $new_b =   $result        & 0xFF;                   /* New blue */
0726 ... 
0727 ...                 $new_color = imagecolorallocate( $img,$new_r,$new_g,$new_b );
0728 ...                 imagesetpixel( $img,$i,$j,$new_color );              /* Set pixel color */
0729 ...             }   /* for( $i=0;$i<$iWidth;$i++ ) */
0730 ...         }   /* for( $j=0;$j<$iHeight;$j++ ) */
0731 ... 
0732 ...         switch ( $szType )                                           /* In function of the file extension */
0733 ...         {
0734 ...             case 'gif' :  $bRetVal = @imagegif( $img,$szTarget );    /* Save the new image to a GIF file */
0735 ...                           break;
0736 ...             case 'png' :  $bRetVal = @imagepng( $img,$szTarget );    /* Save the new image to a PNG file */
0737 ...                           break;
0738 ...             default     : $bRetVal = @imagejpeg( $img,$szTarget,$iQuality );/* Save the new image to a JPG file */
0739 ...         }   /* switch ( $szType ) */
0740 ... 
0741 ...         imagedestroy( $img );                                        /* Releases all the memory associated with the image */
0742 ...     }   /* if ( $img ) */
0743 ... 
0744 ...     return ( $bRetVal );                                            /* Return result to caller */
0745 ... }   /* End of function IMG_Negate() */
0746 ... /* ====================================================================== */
0747 ...  function IMG_Invert( $szImg,$szTarget,$iQuality = 75,$aRect = null ) { return ( IMG_Negate( $szImg,$szTarget,$iQuality,$aRect ) ); }
0748 ... 
0749 ... /* ====================================================================== */
0750 ... /** {{*IMG_Fog( $szImg,$szTarget[,$iTransparency[,$aRect]] )=
0751 ... 
0752 ...     Creates a fog effect
0753 ... 
0754 ...     {*params
0755 ...         $szImg          (string)        Image to be processed
0756 ...         $szTarget       (string)        Image to be saved
0757 ...         $iTransparency  (int)           Optional transparency value (fog effect).
0758 ...                                         [c]63[/c] by default. Value between
0759 ...                                         [c]0[/c] (full opacity) and [c]127[/c] (full
0760 ...                                         transparency)
0761 ...         $aRect          (array)         Optional rectangle. [c]null[/c] by default[br]
0762 ...                                         [c]$aRect[0][/c] = Start x[br]
0763 ...                                         [c]$aRect[1][/c] = Start y[br]
0764 ...                                         [c]$aRect[2][/c] = End x[br]
0765 ...                                         [c]$aRect[3][/c] = End y[br]
0766 ...     *}
0767 ... 
0768 ...     {*return
0769 ...         (bool)          [c]true[/c] if image treated and saved successfully;
0770 ...                         [c]false[/c] if not
0771 ...     *}
0772 ... 
0773 ...     {*warning
0774 ...         Only with .png images
0775 ...     *}
0776 ... 
0777 ...     {*credits
0778 ...         Octavia Andreea Anghel
0779 ...     *}
0780 ... 
0781 ...     {*doc
0782 ...         [url]http://www.devx.com/webdev/Article/37179/0/page/1[/url]
0783 ...     *}
0784 ... 
0785 ...     {*example
0786 ...         $szSrc  = "c:\\images\\transform\\continent.png";
0787 ...         $szDest = "c:\\images\\transform\\continent-fog.png";
0788 ... 
0789 ...         if ( ! FIL_Exists( $szDest ) )
0790 ...         {
0791 ...             IMG_Hue( $szSrc,$szDest );
0792 ...         }
0793 ...     *}
0794 ... 
0795 ...     {*version
0796 ...         1.0.0005
0797 ...     *}
0798 ... 
0799 ...     {*seealso
0800 ...         IMG_Brightness()
0801 ...     *}
0802 ... 
0803 ...     *}}
0804 ...  */
0805 ... /* ====================================================================== */
0806 ... function IMG_Fog( $szImg,$szTarget,$iTransparency = 63,$aRect = null )
0807 ... /*------------------------------------------------------------------*/
0808 ... {
0809 ...     $bRetVal    = false;                                            /* Ready to return a logical false */
0810 ...     $img         = @imagecreatefrompng( $szImg );                   /* Create a new image resource from a PNG file */
0811 ... 
0812 ...     if ( $img )                                                     /* If 'image resource' could be created */
0813 ...     {
0814 ...         /**
0815 ...          *  @todo   Utiliser la fonction générique ImageSize()
0816 ...          */
0817 ... 
0818 ...         $aInfoSize   = getimagesize( $szImg );                      /* Obtain image size */
0819 ...         $iWidth = $aInfoSize[0];                                    /* Determine the width of the image */
0820 ...         $iHeight= $aInfoSize[1];                                    /* Determine the height of the image */
0821 ... 
0822 ...         if ( is_null( $aRect ) )                                    /* If rectangle coordinates NOT passed */
0823 ...         {
0824 ...             $iStartWidth = $iStartHeight = 0;                       /* Use image height and width */
0825 ...             $iEndWidth   = $iWidth; $iEndHeight  = $iHeight;
0826 ...         }   /* if ( is_null( $aRect ) ) */
0827 ...         else   /* Else of ... if ( is_null( $aRect ) ) */
0828 ...         {
0829 ...             $iStartWidth  = $aRect[0];                              /* Start x */
0830 ...             $iStartHeight = $aRect[1];                              /* Start y */
0831 ...             $iEndWidth    = $aRect[2];                              /* End x */
0832 ...             $iEndHeight   = $aRect[3];                              /* End x */
0833 ...         }   /* End of ... Else of ... if ( is_null( $aRect ) ) */
0834 ... 
0835 ...         for ( $j = $iStartHeight;$j < $iEndHeight;$j++ )            /* For each row */
0836 ...         {
0837 ...             for ( $i = $iStartWidth;$i < $iEndWidth;$i++ )          /* For each column */
0838 ...             {
0839 ...                 $aRGB   = COLOR_int2rgb2( imagecolorat( $img,$i,$j ) );/* Obtain pixel RGB at position i,j */
0840 ... 
0841 ...                 imagealphablending( $img,false );                   /* Turn off transparency blending */
0842 ... 
0843 ...                 $color  = imagecolorallocatealpha( $img       ,     /* Image resource */
0844 ...                                                    $aRGB['r'],      /* Red component */
0845 ...                                                    $aRGB['g'],      /* Green component */
0846 ...                                                    $aRGB['b'],      /* Blue component */
0847 ...                                                    $iTransparency );/* Create a new transparent color for image */
0848 ... 
0849 ...                 imagesetpixel( $img,$i,$j,$color );                 /* Set the new color */
0850 ... 
0851 ...                 imagesavealpha( $img,true );                        /* Restore transparency blending */
0852 ...             }   /* for( $i=0;$i<$iWidth;$i++ ) */
0853 ...         }   /* for( $j=0;$j<$iHeight;$j++ ) */
0854 ... 
0855 ...         $bRetVal = imagepng( $img,$szTarget );                      /* Save the PNG image to a file */
0856 ... 
0857 ...         imagedestroy( $img );                                       /* Releases all the memory associated with the image */
0858 ...     }   /* if ( $img ) */
0859 ... 
0860 ...     return ( $bRetVal );                                            /* Return result to caller */
0861 ... }   /* End of function IMG_Fog() */
0862 ... /* ====================================================================== */
0863 ... 
0864 ... /* ====================================================================== */
0865 ... /** {{*IMG_Channel( $img,$szChannel )=
0866 ... 
0867 ...     Keeps the specified channel
0868 ... 
0869 ...     {*params
0870 ...         $img        (resource)      Image resource
0871 ...         $szChannel  (string)        Channel to keep ([c]r[/c], [c]g[/c], [c]b[/c])
0872 ...     *}
0873 ... 
0874 ...     {*return
0875 ...         (void)  The function returns no value
0876 ...     *}
0877 ... 
0878 ...     {*credits
0879 ...         Octavia Andreea Anghel
0880 ...     *}
0881 ... 
0882 ...     {*doc
0883 ...         [url]http://www.devx.com/webdev/Article/37179/0/page/1[/url]
0884 ...     *}
0885 ... 
0886 ...     {*example
0887 ...         $szImg      = "c:\\websites\\mon-site\\images\\jeu-eau.jpg";
0888 ...         $szDest     = "c:\\websites\\mon-site\\images\\jeu-eau-bis.jpg";
0889 ...         $szType     = '';                                // Image type ('gif', 'png', 'jpg' ...)
0890 ...         $img        = OpenImage( $szImg,$szType );       // Open image
0891 ... 
0892 ...         if ( $img )                                      // If 'image resource' successfully created
0893 ...         {
0894 ...             $iQuality   = 80;                            // 0 <= JPG quality <= 100
0895 ...             IMG_Channel( $img,'r' );                     // Change the red channel
0896 ...             SaveImage( $img,$szDest,$szType,$iQuality ); // Save image
0897 ...             imagedestroy( $img );                        // Releases all the memory associated with the image
0898 ...         }
0899 ...     *}
0900 ... 
0901 ...     {*version
0902 ...         1.0.0005
0903 ...     *}
0904 ... 
0905 ...     {*seealso
0906 ...         IMG_RedChannel(), IMG_GreenChannel(), IMG_BlueChannel()
0907 ...     *}
0908 ... 
0909 ...     *}}
0910 ...  */
0911 ... /* ====================================================================== */
0912 ... function IMG_Channel( &$img,$szChannel )
0913 ... /*------------------------------------*/
0914 ... {
0915 ...     /**
0916 ...     *  @todo   Utiliser une array de coordonnées de rectangle de traitement
0917 ...     */
0918 ... 
0919 ...     $iWidth  = imagesx( $img );
0920 ...     $iHeight = imagesy( $img );
0921 ... 
0922 ...     switch ( $szChannel )
0923 ...     {
0924 ...         case 'r':
0925 ...             for( $j=0;$j<$iHeight;$j++ )                                    /* For each row */
0926 ...             {
0927 ...                 for( $i=0;$i<$iWidth;$i++ )                                 /* For each column */
0928 ...                 {
0929 ...                     $aRGB   = COLOR_int2rgb2( imagecolorat( $img,$i,$j ) ); /* Obtain pixel RGB */
0930 ...                     $pixel  = imagecolorallocate( $img,$aRGB['r'],0,0 );    /* Change red channel */
0931 ...                     imagesetpixel( $img,$i,$j,$pixel );                     /* Set pixel color */
0932 ...                 }   /* for( $i=0;$i<$iWidth;$i++ ) */
0933 ...             }   /* for( $j=0;$j<$iHeight;$j++ ) */
0934 ...             break;
0935 ...         case 'g':
0936 ...             for( $j=0;$j<$iHeight;$j++ )                                    /* For each row */
0937 ...             {
0938 ...                 for( $i=0;$i<$iWidth;$i++ )                                 /* For each column */
0939 ...                 {
0940 ...                     $aRGB   = COLOR_int2rgb2( imagecolorat( $img,$i,$j ) ); /* Obtain pixel RGB */
0941 ...                     $pixel  = imagecolorallocate( $img,0,$aRGB['g'],0 );    /* Change green channel */
0942 ...                     imagesetpixel( $img,$i,$j,$pixel );                     /* Set pixel color */
0943 ...                 }   /* for( $i=0;$i<$iWidth;$i++ ) */
0944 ...             }   /* for( $j=0;$j<$iHeight;$j++ ) */
0945 ...             break;
0946 ...         default :
0947 ...             for( $j=0;$j<$iHeight;$j++ )                                    /* For each row */
0948 ...             {
0949 ...                 for( $i=0;$i<$iWidth;$i++ )                                 /* For each column */
0950 ...                 {
0951 ...                     $aRGB   = COLOR_int2rgb2( imagecolorat( $img,$i,$j ) ); /* Obtain pixel RGB */
0952 ...                     $pixel  = imagecolorallocate( $img,0,0,$aRGB['b'] );    /* Change blue channel */
0953 ...                     imagesetpixel( $img,$i,$j,$pixel );                     /* Set pixel color */
0954 ...                 }   /* for( $i=0;$i<$iWidth;$i++ ) */
0955 ...             }   /* for( $j=0;$j<$iHeight;$j++ ) */
0956 ...             break;
0957 ...     }   /* switch ( $szChannel ) */
0958 ... }   /* End of function IMG_Channel() */
0959 ... /* ====================================================================== */
0960 ... 
0961 ... /* ====================================================================== */
0962 ... /** {{*IMG_RedChannel( $szImg,$szTarget[,$iQuality] )=
0963 ... 
0964 ...     Keeps the red channel only
0965 ... 
0966 ...     {*params
0967 ...         $szImg      (string)        Image to be processed
0968 ...         $szTarget   (string)        Image to be saved
0969 ...         $iQuality   (int)           Optional quality required when saving the
0970 ...                                     image. [c]75[/c] by default. Applies to
0971 ...                                     .jpg images only.
0972 ...     *}
0973 ... 
0974 ...     {*return
0975 ...         (bool)          [c]true[/c] if image treated and saved successfully;
0976 ...                         [c]false[/c] if not
0977 ...     *}
0978 ... 
0979 ...     {*credits
0980 ...         Octavia Andreea Anghel
0981 ...     *}
0982 ... 
0983 ...     {*doc
0984 ...         [url]http://www.devx.com/webdev/Article/37179/0/page/1[/url]
0985 ...     *}
0986 ... 
0987 ...     {*example
0988 ...         $szImgSrc  = "c:\\websites\\mon-site\\images\\jeu-eau.jpg";
0989 ... 
0990 ...         $szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-bis.jpg";
0991 ...         IMG_RedChannel( $szImgSrc,$szImgDest,95 );
0992 ... 
0993 ...         $szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-ter.jpg";
0994 ...         IMG_GreenChannel( $szImgSrc,$szImgDest,95 );
0995 ... 
0996 ...         $szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-quater.jpg";
0997 ...         IMG_BlueChannel( $szImgSrc,$szImgDest,95 );
0998 ...     *}
0999 ... 
1000 ...     {*version
1001 ...         1.0.0005
1002 ...     *}
1003 ... 
1004 ...     {*seealso
1005 ...         IMG_GreenChannel(), IMG_BlueChannel(), IMG_Channel()
1006 ...     *}
1007 ... 
1008 ...     *}}
1009 ...  */
1010 ... /* ====================================================================== */
1011 ... function IMG_RedChannel( $szImg,$szTarget,$iQuality = 75 )
1012 ... /*------------------------------------------------------*/
1013 ... {
1014 ...     /**
1015 ...     *  @todo   Utiliser une array de coordonnées de rectangle de traitement
1016 ...     */
1017 ...     $bRetVal    = false;                                            /* Ready to return a logical false */
1018 ...     $szType     = '';                                               /* Image type ('gif', 'png', 'jpg' ...) */
1019 ...     $img        = OpenImage( $szImg,$szType );                      /* Open image */
1020 ... 
1021 ...     if ( $img )                                                     /* If 'image resource' successfully created */
1022 ...     {
1023 ...         $iQuality   = max( min( $iQuality,100 ),0 );                /* 0 <= JPG quality <= 100 */
1024 ...         IMG_Channel( $img,'r' );                                    /* Change the red channel */
1025 ...         $bRetVal = SaveImage( $img,$szTarget,$szType,$iQuality );   /* Save image */
1026 ...         imagedestroy( $img );                                       /* Releases all the memory associated with the image */
1027 ...     }   /* if ( $img ) */
1028 ... 
1029 ...     return ( $bRetVal );                                            /* Return result to caller */
1030 ... }   /* End of function IMG_RedChannel() */
1031 ... /* ====================================================================== */
1032 ... 
1033 ... /* ====================================================================== */
1034 ... /** {{*IMG_GreenChannel( $szImg,$szTarget[,$iQuality] )=
1035 ... 
1036 ...     Keeps the green channel only
1037 ... 
1038 ...     {*params
1039 ...         $szImg      (string)        Image to be processed
1040 ...         $szTarget   (string)        Image to be saved
1041 ...         $iQuality   (int)           Optional quality required when saving the
1042 ...                                     image. [c]75[/c] by default. Applies to
1043 ...                                     .jpg images only.
1044 ...     *}
1045 ... 
1046 ...     {*return
1047 ...         (bool)          [c]true[/c] if image treated and saved successfully;
1048 ...                         [c]false[/c] if not
1049 ...     *}
1050 ... 
1051 ...     {*credits
1052 ...         Octavia Andreea Anghel
1053 ...     *}
1054 ... 
1055 ...     {*doc
1056 ...         [url]http://www.devx.com/webdev/Article/37179/0/page/1[/url]
1057 ...     *}
1058 ... 
1059 ...     {*example
1060 ...         $szImgSrc  = "c:\\websites\\mon-site\\images\\jeu-eau.jpg";
1061 ... 
1062 ...         $szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-bis.jpg";
1063 ...         IMG_RedChannel( $szImgSrc,$szImgDest,95 );
1064 ... 
1065 ...         $szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-ter.jpg";
1066 ...         IMG_GreenChannel( $szImgSrc,$szImgDest,95 );
1067 ... 
1068 ...         $szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-quater.jpg";
1069 ...         IMG_BlueChannel( $szImgSrc,$szImgDest,95 );
1070 ...     *}
1071 ... 
1072 ...     {*version
1073 ...         1.0.0005
1074 ...     *}
1075 ... 
1076 ...     {*seealso
1077 ...         IMG_RedChannel(), IMG_BlueChannel(), IMG_Channel()
1078 ...     *}
1079 ... 
1080 ...     *}}
1081 ...  */
1082 ... /* ====================================================================== */
1083 ... function IMG_GreenChannel( $szImg,$szTarget,$iQuality = 75 )
1084 ... /*--------------------------------------------------------*/
1085 ... {
1086 ...     /**
1087 ...     *  @todo   Utiliser une array de coordonnées de rectangle de traitement
1088 ...     */
1089 ...     $bRetVal    = false;                                            /* Ready to return a logical false */
1090 ...     $szType     = '';                                               /* Image type ('gif', 'png', 'jpg' ...) */
1091 ...     $img        = OpenImage( $szImg,$szType );                      /* Open image */
1092 ... 
1093 ...     if ( $img )                                                     /* If 'image resource' successfully created */
1094 ...     {
1095 ...         $iQuality   = max( min( $iQuality,100 ),0 );                /* 0 <= JPG quality <= 100 */
1096 ...         IMG_Channel( $img,'g' );                                    /* Change the green channel */
1097 ...         $bRetVal = SaveImage( $img,$szTarget,$szType,$iQuality );   /* Save image */
1098 ...         imagedestroy( $img );                                       /* Releases all the memory associated with the image */
1099 ...     }   /* if ( $img ) */
1100 ... 
1101 ...     return ( $bRetVal );                                            /* Return result to caller */
1102 ... }   /* End of function IMG_GreenChannel() =============================== */
1103 ... 
1104 ... /* ====================================================================== */
1105 ... /** {{*IMG_BlueChannel( $szImg,$szTarget[,$iQuality] )=
1106 ... 
1107 ...     Keeps the red channel only
1108 ... 
1109 ...     {*params
1110 ...         $szImg      (string)        Image to be processed
1111 ...         $szTarget   (string)        Image to be saved
1112 ...         $iQuality   (int)           Optional quality required when saving the
1113 ...                                     image. [c]75[/c] by default. Applies to
1114 ...                                     .jpg images only.
1115 ...     *}
1116 ... 
1117 ...     {*return
1118 ...         (bool)          [c]true[/c] if image treated and saved successfully;
1119 ...                         [c]false[/c] if not
1120 ...     *}
1121 ... 
1122 ...     {*credits
1123 ...         Octavia Andreea Anghel
1124 ...     *}
1125 ... 
1126 ...     {*doc
1127 ...         [url]http://www.devx.com/webdev/Article/37179/0/page/1[/url]
1128 ...     *}
1129 ... 
1130 ...     {*example
1131 ...         $szImgSrc  = "c:\\websites\\mon-site\\images\\jeu-eau.jpg";
1132 ... 
1133 ...         $szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-bis.jpg";
1134 ...         IMG_RedChannel( $szImgSrc,$szImgDest,95 );
1135 ... 
1136 ...         $szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-ter.jpg";
1137 ...         IMG_GreenChannel( $szImgSrc,$szImgDest,95 );
1138 ... 
1139 ...         $szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-quater.jpg";
1140 ...         IMG_BlueChannel( $szImgSrc,$szImgDest,95 );
1141 ...     *}
1142 ... 
1143 ...     {*version
1144 ...         1.0.0005
1145 ...     *}
1146 ... 
1147 ...     {*seealso
1148 ...         IMG_GreenChannel(), IMG_RedChannel(), IMG_Channel()
1149 ...     *}
1150 ... 
1151 ...     *}}
1152 ...  */
1153 ... /* ====================================================================== */
1154 ... function IMG_BlueChannel( $szImg,$szTarget,$iQuality = 75 )
1155 ... /*-------------------------------------------------------*/
1156 ... {
1157 ...     /**
1158 ...     *  @todo   Utiliser une array de coordonnées de rectangle de traitement
1159 ...     */
1160 ...     $bRetVal    = false;                                            /* Ready to return a logical false */
1161 ...     $szType     = '';                                               /* Image type ('gif', 'png', 'jpg' ...) */
1162 ...     $img        = OpenImage( $szImg,$szType );                      /* Open image */
1163 ... 
1164 ...     if ( $img )                                                     /* If 'image resource' successfully created */
1165 ...     {
1166 ...         $iQuality   = max( min( $iQuality,100 ),0 );                /* 0 <= JPG quality <= 100 */
1167 ...         IMG_Channel( $img,'b' );                                    /* Change the blue channel */
1168 ...         $bRetVal = SaveImage( $img,$szTarget,$szType,$iQuality );   /* Save image */
1169 ...         imagedestroy( $img );                                       /* Releases all the memory associated with the image */
1170 ...     }   /* if ( $img ) */
1171 ... 
1172 ...     return ( $bRetVal );                                            /* Return result to caller */
1173 ... }   /* End of function IMG_BlueChannel() ================================ */
1174 ... 
1175 ... /* ====================================================================== */
1176 ... /** {{*IMG_SaveAs( $szImg,$szTarget,$szType,$iQuality = 75 )=
1177 ... 
1178 ...     Saves an image in another format
1179 ... 
1180 ...     {*params
1181 ...         $szImg      (string)        Image to be processed
1182 ...         $szTarget   (string)        Target filename
1183 ...         $szType     (string)        Image type
1184 ...         $iQuality   (int)           Optional quality required when saving the
1185 ...                                     image. [c]75[/c] by default. Applies to
1186 ...                                     .jpg images only.
1187 ...     *}
1188 ... 
1189 ...     {*return
1190 ...         (bool)          [c]true[/c] if image saved successfully;
1191 ...                         [c]false[/c] if not
1192 ...     *}
1193 ... 
1194 ...     {*version
1195 ...         1.0.0005
1196 ...     *}
1197 ... 
1198 ...     {*mdate
1199 ...         30/06/2013 17:50
1200 ...     *}
1201 ... 
1202 ...     {*seealso
1203 ...         IMG_Save()
1204 ...     *}
1205 ... 
1206 ...     *}}
1207 ...  */
1208 ... /* ====================================================================== */
1209 ... function IMG_SaveAs( $szImg,$szTarget,$szType,$iQuality = 75 )
1210 ... /*----------------------------------------------------------*/
1211 ... {
1212 ...     $bRetVal    = false;                                            /* Ready to return a logical false */
1213 ...     $szType     = '';                                               /* Image type ('gif', 'png', 'jpg' ...) */
1214 ...     $img        = OpenImage( $szImg,$szType );                      /* Open image */
1215 ... 
1216 ...     if ( $img )                                                     /* If 'image resource' successfully created */
1217 ...     {
1218 ...         $bRetVal = SaveImage( $img,$szTarget,$szType,$iQuality );   /* Save image */
1219 ...         imagedestroy( $img );                                       /* Releases all the memory associated with the image */
1220 ...     }   /* if ( $img ) */
1221 ... 
1222 ...     return ( $bRetVal );                                            /* Return result to caller */
1223 ... }   /* End of function IMG_SaveAs() ===================================== */
1224 ... 
1225 ... /* ====================================================================== */
1226 ... /** {{*IMG_AverageColor( $szImg,$aRect )=
1227 ... 
1228 ...     Determines the average color of an image. Useful to categorize
1229 ...     images based on the prominent color.
1230 ... 
1231 ...     {*params
1232 ...         $szImg      (string)    Image file
1233 ...         $aRect      (array)     Optional rectangle to consider
1234 ...     *}
1235 ... 
1236 ...     {*return
1237 ...         (array)     An associative array depicting RGB values:
1238 ...                     $aColor['r'][br]
1239 ...                     $aColor['g'][br]
1240 ...                     $aColor['b'][br]
1241 ...     *}
1242 ... 
1243 ...     {*version
1244 ...         1.0.0005
1245 ...     *}
1246 ... 
1247 ...     {*mdate
1248 ...         30/06/2013 17:50
1249 ...     *}
1250 ... 
1251 ...     {*seealso
1252 ...         IMG_Save()
1253 ...     *}
1254 ... 
1255 ...     *}}
1256 ...  */
1257 ... /* ====================================================================== */
1258 ... function IMG_AverageColor( $szImg,$aRect = null )
1259 ... /*---------------------------------------------*/
1260 ... {
1261 ...     $aColor    = array( 'r' => 0,'g' => 0,'b' => 0 );               /* Ready to return a color (RGB) */
1262 ...     $szType     = '';                                               /* Image type ('gif', 'png', 'jpg' ...) */
1263 ...     $img        = OpenImage( $szImg,$szType );                      /* Open image */
1264 ... 
1265 ...     if ( $img )                                                     /* If 'image resource' successfully created */
1266 ...     {
1267 ...         $iWidth = $iHeight = 0; ImageSize( $szImg,$iWidth,$iHeight );/* Obtain image info (width and height are updated ) */
1268 ... 
1269 ...         if ( is_null( $aRect ) )                                    /* If rectangle coordinates NOT passed */
1270 ...         {
1271 ...             $iStartWidth = $iStartHeight = 0;                       /* Use image height and width */
1272 ...             $iEndWidth   = $iWidth; $iEndHeight  = $iHeight;
1273 ...         }   /* if ( is_null( $aRect ) ) */
1274 ...         else   /* Else of ... if ( is_null( $aRect ) ) */
1275 ...         {
1276 ...             $iStartWidth  = $aRect[0];                              /* Start x */
1277 ...             $iStartHeight = $aRect[1];                              /* Start y */
1278 ...             $iEndWidth    = $aRect[2];                              /* End x */
1279 ...             $iEndHeight   = $aRect[3];                              /* End x */
1280 ...         }   /* End of ... Else of ... if ( is_null( $aRect ) ) */
1281 ... 
1282 ...         for( $j = $iStartHeight;$j < $iEndHeight;$j++ )             /* For each row */
1283 ...         {
1284 ...             for( $i = $iStartWidth;$i < $iEndWidth;$i++ )           /* For each column */
1285 ...             {
1286 ...                 $aRGB   = COLOR_int2rgb2( imagecolorat( $img,$i,$j ) );/* Obtain pixel RGB at position i,j */
1287 ...                 $aColor['r'] += $aRGB['r'];
1288 ...                 $aColor['g'] += $aRGB['g'];
1289 ...                 $aColor['b'] += $aRGB['b'];
1290 ...             }   /* for( $i=0;$i<$iWidth;$i++ ) */
1291 ...         }   /* for( $j=0;$j<$iHeight;$j++ ) */
1292 ... 
1293 ...         $nPixels = ( $iEndHeight - $iStartHeight + 1 ) * ( $iEndWidth - $iStartWidth + 1 );
1294 ... 
1295 ...         //$aColor['r'] = (int) round( $aColor['r'] / ( $iWidth * $iHeight ),0 ) ;
1296 ...         //$aColor['g'] = (int) round( $aColor['g'] / ( $iWidth * $iHeight ),0 ) ;
1297 ...         //$aColor['b'] = (int) round( $aColor['b'] / ( $iWidth * $iHeight ),0 ) ;
1298 ... 
1299 ...         $aColor['r'] = (int) round( $aColor['r'] / $nPixels,0 ) ;
1300 ...         $aColor['g'] = (int) round( $aColor['g'] / $nPixels,0 ) ;
1301 ...         $aColor['b'] = (int) round( $aColor['b'] / $nPixels,0 ) ;
1302 ... 
1303 ...         imagedestroy( $img );                                       /* Releases all the memory associated with the image */
1304 ...     }   /* if ( $img ) */
1305 ... 
1306 ...     return ( $aColor );                                             /* Return result to caller */
1307 ... }   /* End of function IMG_AverageColor() */
1308 ... /* ====================================================================== */
1309 ... 
1310 ...     /* ====================================================================== */
1311 ...     /**
1312 ...      *  Redimensionne une image suivant un facteur de réduction
1313 ...      *  (2 divise la taille de l'image en deux)
1314 ...      *  @since      version 1.0.0005
1315 ...      *  @param      string      $szImg      Image à traiter
1316 ...      *  @param      string      $szTarget   Image résultat
1317 ...      *  @param      int         $iFactor    Degré de réduction (2 ... divise les
1318 ...      *                                      dimensions par 2; 3 ... l'image est
1319 ...      *                                      réduite à un tiers de sa taille)
1320 ...      *  @param      int         $iQuality   Qualité de l'image à sauver (JPG)
1321 ...      *  @return     bool                    vrai (true) si l'image a été
1322 ...      *                                      transformée; faux (false) dans le
1323 ...      *                                      cas contraire.
1324 ... 
1325 ...     /* ====================================================================== */
1326 ...     function IMG_Resize( $szImg,$szTarget,$iFactor,$iQuality = 75 )
1327 ...     /*-----------------------------------------------------------*/
1328 ...     {
1329 ...         $bRetVal    = false;                                            /* Ready to return a logical false */
1330 ...         $szType     = '';                                               /* Image type ('gif', 'png', 'jpg' ...) */
1331 ...         $img        = OpenImage( $szImg,$szType );                      /* Open image */
1332 ... 
1333 ...         if ( $img )                                                     /* If 'image resource' successfully created */
1334 ...         {
1335 ...             $iQuality = max( min( $iQuality,100 ),0 );                  /* 0 <= JPG quality <= 100 */
1336 ... 
1337 ...             $iWidth = $iHeight = 0; ImageSize( $szImg,$iWidth,$iHeight );/* Obtain image info (width and height are updated ) */
1338 ... 
1339 ...             $iNewWidth  = (int) round( ( $iWidth  / $iFactor ),0 );     /* New width */
1340 ...             $iNewHeight = (int) round( ( $iHeight / $iFactor ),0 );     /* New height */
1341 ... 
1342 ...             $tmp        = imagecreatetruecolor( $iNewWidth,$iNewHeight ); /* Create new image */
1343 ... 
1344 ...             if ( $tmp )                                                 /* If new image successfully created */
1345 ...             {
1346 ...                 imagecopyresized( $tmp,$img,                            /* Destination image, source image */
1347 ...                                   0,0,                                  /* Destination X, Destination Y */
1348 ...                                   0,0,                                  /* Source X, Source Y */
1349 ...                                   $iNewWidth,$iNewHeight,               /* New width, new height */
1350 ...                                   $iWidth,$iHeight );                   /* Old width, old height */
1351 ... 
1352 ...                 $bRetVal = SaveImage( $tmp,$szTarget,$szType,$iQuality );  /* Save image */
1353 ...                 imagedestroy( $tmp );                                   /* Releases all the memory associated with the image */
1354 ...             }   /* if ( $tmp ) */
1355 ... 
1356 ...             imagedestroy( $img );                                       /* Releases all the memory associated with the image */
1357 ...         }   /* if ( $img ) */
1358 ... 
1359 ...         return ( $bRetVal );                                            /* Return result to caller */
1360 ...     }   /* End of function IMG_Resize() */
1361 ...     /* ====================================================================== */
1362 ... 
1363 ...     function IMG_Scale( $szImg,$szTarget,$iFactor,$iQuality = 75 ){ return IMG_Resize( $szImg,$szTarget,$iFactor,$iQuality = 75 ); }
1364 ... 
1365 ... 
1366 ...     /* ====================================================================== */
1367 ...     /**
1368 ...      *  Redimensionne une image selon une taille donnée (largeur et hauteur)
1369 ...      *  @since      version 1.0.0005
1370 ...      *  @param      string      $szImg      Image à traiter
1371 ...      *  @param      string      $szTarget   Image résultat
1372 ...      *  @param      int         $iNewWidth  Nouvelle largeur de l'image
1373 ...      *  @param      int         $iNewHeight Nouvelle hauteur de l'image
1374 ...      *  @param      int         $iQuality   Qualité de l'image à sauver (JPG)
1375 ...      *  @return     bool                    vrai (true) si l'image a été
1376 ...      *                                      redimensionnée; faux (false) dans le
1377 ...      *                                      cas contraire.
1378 ... 
1379 ...     /* ====================================================================== */
1380 ...     function IMG_Redimension( $szImg,$szTarget,$iNewWidth,$iNewHeight,$iQuality = 75 )
1381 ...     /*------------------------------------------------------------------------------*/
1382 ...     {
1383 ...         $bRetVal    = false;                                            /* Ready to return a logical false */
1384 ...         $szType     = '';                                               /* Image type ('gif', 'png', 'jpg' ...) */
1385 ...         $img        = OpenImage( $szImg,$szType );                      /* Open image */
1386 ... 
1387 ...         if ( $img )                                                     /* If 'image resource' successfully created */
1388 ...         {
1389 ...             $iQuality = max( min( $iQuality,100 ),0 );                  /* 0 <= JPG quality <= 100 */
1390 ... 
1391 ...             $iWidth = $iHeight = 0; ImageSize( $szImg,$iWidth,$iHeight );/* Obtain image info (width and height are updated ) */
1392 ... 
1393 ...             $tmp    = imagecreatetruecolor( $iNewWidth,$iNewHeight );   /* Create new image */
1394 ... 
1395 ...             if ( $tmp )                                                 /* If new image successfully created */
1396 ...             {
1397 ...                 imagecopyresized( $tmp,$img,                            /* Destination image, source image */
1398 ...                                   0,0,                                  /* Destination X, Destination Y */
1399 ...                                   0,0,                                  /* Source X, Source Y */
1400 ...                                   $iNewWidth,$iNewHeight,               /* New width, new height */
1401 ...                                   $iWidth,$iHeight );                   /* Old width, old height */
1402 ... 
1403 ...                 $bRetVal = SaveImage( $tmp,$szTarget,$szType,$iQuality );  /* Save image */
1404 ...                 imagedestroy( $tmp );                                   /* Releases all the memory associated with the image */
1405 ...             }   /* if ( $tmp ) */
1406 ... 
1407 ...             imagedestroy( $img );                                       /* Releases all the memory associated with the image */
1408 ...         }   /* if ( $img ) */
1409 ... 
1410 ...         return ( $bRetVal );                                            /* Return result to caller */
1411 ...     }   /* End of function IMG_Redimension() */
1412 ...     /* ====================================================================== */
1413 ... 
1414 ...     /* ====================================================================== */
1415 ...     /** DO NOT USE SO FAR
1416 ...      *  Crée un onglet (thumbnail)
1417 ...      *  @since      version 1.0.0005
1418 ...      *  @param      string      $szImg      Image à traiter
1419 ...      *  @param      string      $szTarget   Image résultat
1420 ...      */
1421 ...     /* ====================================================================== */
1422 ...     function IMG_Thumbnail($img, $imgPath, $suffix, $newWidth, $newHeight,$quality)
1423 ...     /*-----------------------------------------------------------------------------*/
1424 ...     {
1425 ...         // Open the original image.
1426 ...         $original = imagecreatefromjpeg("$imgPath/$img") or die("Error Opening original");
1427 ...         list($width, $height, $type, $attr) = getimagesize("$imgPath/$img");
1428 ... 
1429 ...         // Resample the image.
1430 ...         $tempImg = imagecreatetruecolor($newWidth, $newHeight) or die("Cant create temp image");
1431 ...         imagecopyresized($tempImg, $original, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
1432 ... 
1433 ...         // Create the new file name.
1434 ...         $newNameE = explode(".", $img);
1435 ...         $newName = ?. $newNameE[0] .?. $suffix .?.?. $newNameE[1] .?;
1436 ... 
1437 ...         // Save the image.
1438 ...         imagejpeg($tempImg, "$imgPath/$newName", $quality) or die("Cant save image");
1439 ... 
1440 ...         // Clean up.
1441 ...         imagedestroy($original);
1442 ...         imagedestroy($tempImg);
1443 ...         return true;
1444 ...     }
1445 ...     /* ====================================================================== */
1446 ...     /* ====================================================================== */
1447 ...     /**
1448 ...      *  Inverse une image horizontalement, verticalement ou dans les 2 sens
1449 ...      *  @since      version 2.0.0009
1450 ...      *  @param      string      $szImg      Image à traiter
1451 ...      *  @param      string      $szTarget   Image résultat
1452 ...      *  @param      string      $szDir      Direction du flip
1453 ...      *  @param      int         $iQuality   Qualité de l'image à sauver (JPG)
1454 ...      *  @return     bool                    vrai (true) si l'image a été
1455 ...      *                                      transformée; faux (false) dans le
1456 ...      *                                      cas contraire.
1457 ...     /* ====================================================================== */
1458 ...     function IMG_Flip( $szImg,$szTarget,$szDir = 'hori',$iQuality = 75 )
1459 ...     /*----------------------------------------------------------------*/
1460 ...     {
1461 ...         $bRetVal    = false;                                            /* Ready to return a logical false */
1462 ...         $bToSave    = false;                                            /* Should we save the image */
1463 ...         $szType     = '';                                               /* Image type ('gif', 'png', 'jpg' ...) */
1464 ...         $img        = OpenImage( $szImg,$szType );                      /* Open image */
1465 ... 
1466 ...         if ( $img )                                                     /* If 'image resource' successfully created */
1467 ...         {
1468 ...             $iQuality = max( min( $iQuality,100 ),0 );                  /* 0 <= JPG quality <= 100 */
1469 ...             $iWidth   = $iHeight = 0; ImageSize( $szImg,$iWidth,$iHeight );/* Obtain image info (width and height are updated ) */
1470 ...             $tmp      = imagecreatetruecolor( $iWidth,$iHeight );       /* Create a destination image */
1471 ... 
1472 ...             switch ( $szDir )                                           /* Whic direction for the flip? */
1473 ...             {
1474 ...                 case 'vert' :   for( $i=0;$i<$iHeight;$i++ )
1475 ...                                 {
1476 ...                                     imagecopy( $tmp,$img,0,( $iHeight - $i - 1 ),0,$i,$iWidth,1 );
1477 ...                                 }
1478 ...                                 $bToSave = true;                        /* We must save the image */
1479 ...                                 break;
1480 ...                 case 'hori' :   for( $i=0;$i<$iWidth;$i++ )
1481 ...                                 {
1482 ...                                     imagecopy( $tmp,$img,( $iWidth - $i - 1 ),0,$i,0,1,$iHeight );
1483 ...                                 }
1484 ...                                 $bToSave = true;                        /* We must save the image */
1485 ...                                 break;
1486 ...                 case 'both' :   for( $i=0;$i<$iWidth;$i++ )
1487 ...                                 {
1488 ...                                     imagecopy( $tmp,$img,( $iWidth - $i - 1 ),0,$i,0,1,$iHeight );
1489 ...                                 }
1490 ... 
1491 ...                                 $buffer = imagecreatetruecolor( $iWidth,1 );
1492 ... 
1493 ...                                 for( $i=0;$i<( $iHeight/2 );$i++ )
1494 ...                                 {
1495 ...                                     imagecopy( $buffer,$tmp,0,0,0,( $iHeight - $i -1 ),$iWidth,1 );
1496 ...                                     imagecopy( $tmp,$tmp,0,($iHeight - $i - 1), 0, $i,$iWidth,1 );
1497 ...                                     imagecopy( $tmp,$buffer,0,$i,0,0,$iWidth,1 );
1498 ...                                 }
1499 ... 
1500 ...                                 imagedestroy( $buffer );
1501 ... 
1502 ...                                 $bToSave = true;                        /* We must save the image */
1503 ...                                 break;
1504 ...             }   /* switch ( $szDir ) */
1505 ... 
1506 ...             if ( $bToSave )                                             /* If image must be saved */
1507 ...             {
1508 ...                 $bRetVal = SaveImage( $tmp,$szTarget,$szType,$iQuality );/* Save image */
1509 ...             }   /* if ( $bToSave ) */
1510 ... 
1511 ...             imagedestroy( $tmp );                                       /* Releases all the memory associated with the temporary image */
1512 ...             imagedestroy( $img );                                       /* Releases all the memory associated with the original image */
1513 ...         }   /* if ( $img ) */
1514 ... 
1515 ...         return ( $bRetVal );                                            /* Return result to caller */
1516 ...     }   /* End of function IMG_Flip() */
1517 ...     /* ====================================================================== */
1518 ... 
1519 ...     /* ====================================================================== */
1520 ...     /**
1521 ...      *  Colorie une image en fonction d'une teinte donnée
1522 ...      *  @credits    Paul Hudson
1523 ...      *  @link       http://www.hudzilla.org/php/11_2_21.php
1524 ...      *  @lastmodifiedby Patrick Boens
1525 ...      *  @since      version 1.0.0005
1526 ...      *  @param      string      $szImg      Image à traiter
1527 ...      *  @param      string      $szTarget   Image résultat
1528 ...      *  @param      array       $aRGBTint   Tableau RGB de la teinte à attribuer
1529 ...      *                                      à l'image.
1530 ...      *  @param      int         $fSat       Degré de saturation souhaité. La
1531 ...      *                                      saturation est une valeur soit entre
1532 ...      *                                      0 et 1 ou -1 : 0 = les couleurs sont
1533 ...      *                                      inexistantes (niveaux de gris);
1534 ...      *                                      1 = les couleurs sont complètement
1535 ...      *                                      saturées; -1 = aucune saturation
1536 ...      *                                      n'est appliquée.
1537 ...      *  @param      int         $iQuality   Qualité de l'image à sauver (JPG)
1538 ...      *  @return     bool                    vrai (true) si l'image a été
1539 ...      *                                      transformée; faux (false) dans le
1540 ...      *                                      cas contraire.
1541 ...      */
1542 ...     /* ====================================================================== */
1543 ...     function IMG_Colorize( $szImg,$szTarget,$aRGBTint,$fSat = -1,$iQuality = 75,$aRect = null )
1544 ...     /*---------------------------------------------------------------------------------------*/
1545 ...     {
1546 ...         $bRetVal    = false;                                            /* Ready to return a logical false */
1547 ...         $szType     = '';                                               /* Image type ('gif', 'png', 'jpg' ...) */
1548 ...         $img        = OpenImage( $szImg,$szType );                      /* Open image */
1549 ... 
1550 ...         if ( $img )                                                     /* If 'image resource' successfully created */
1551 ...         {
1552 ...             $iQuality = max( min( $iQuality,100 ),0 );                  /* 0 <= JPG quality <= 100 */
1553 ... 
1554 ...             $iWidth = $iHeight = 0; ImageSize( $szImg,$iWidth,$iHeight );/* Obtain image info (width and height are updated ) */
1555 ... 
1556 ...             if ( $fSat != -1 )                                          /* If we must apply a given saturation */
1557 ...             {
1558 ...                 $aHSL       = COLOR_rgb2hsl( $aRGBTint );               /* Turn RGB to HSL */
1559 ...                 $aHSL['s']  = $fSat;                                    /* Modify saturation */
1560 ...                 $aRGBTint   = COLOR_hsl2rgb( $aHSL );                   /* Turn HSL to RGB */
1561 ...             }   /* if ( $fSat != -1 ) */
1562 ... 
1563 ...             if ( is_null( $aRect ) )                                    /* If rectangle coordinates NOT passed */
1564 ...             {
1565 ...                 $iStartWidth = $iStartHeight = 0;                       /* Use image height and width */
1566 ...                 $iEndWidth   = $iWidth; $iEndHeight  = $iHeight;
1567 ...             }   /* if ( is_null( $aRect ) ) */
1568 ...             else   /* Else of ... if ( is_null( $aRect ) ) */
1569 ...             {
1570 ...                 $iStartWidth  = $aRect[0];                              /* Start x */
1571 ...                 $iStartHeight = $aRect[1];                              /* Start y */
1572 ...                 $iEndWidth    = $aRect[2];                              /* End x */
1573 ...                 $iEndHeight   = $aRect[3];                              /* End x */
1574 ...             }   /* End of ... Else of ... if ( is_null( $aRect ) ) */
1575 ... 
1576 ...             for ( $j = $iStartHeight;$j < $iEndHeight;$j++ )            /* For each row */
1577 ...             {
1578 ...                 for ( $i = $iStartWidth;$i < $iEndWidth;$i++ )          /* For each column */
1579 ...                 {
1580 ...                     $aRGB   = COLOR_int2rgb2( imagecolorat( $img,$i,$j ) );/* Obtain pixel RGB at position i,j */
1581 ... 
1582 ...                     $iGray  = (int) ( ( $aRGB['r'] +
1583 ...                                         $aRGB['g'] +
1584 ...                                         $aRGB['b'] ) / 3 );             /* Grayscale */
1585 ... 
1586 ...                     $iRed   = max( min( $iGray + $aRGBTint['r'],255 ),0 );/* New red color */
1587 ...                     $iGreen = max( min( $iGray + $aRGBTint['g'],255 ),0 );/* New green color */
1588 ...                     $iBlue  = max( min( $iGray + $aRGBTint['b'],255 ),0 );/* New blue color */
1589 ... 
1590 ...                     $pixel  = imagecolorallocate ( $img,$iRed,$iGreen,$iBlue );
1591 ...                     imagesetpixel( $img,$i,$j,$pixel );                 /* Set pixel color to blue */
1592 ...                 }   /* for( $i=0;$i<$iWidth;$i++ ) */
1593 ...             }   /* for( $j=0;$j<$iHeight;$j++ ) */
1594 ... 
1595 ...             $bRetVal = SaveImage( $img,$szTarget,$szType,$iQuality );   /* Save image */
1596 ... 
1597 ...             imagedestroy( $img );                                       /* Releases all the memory associated with the image */
1598 ...         }   /* if ( $img ) */
1599 ... 
1600 ...         return ( $bRetVal );                                            /* Return result to caller */
1601 ...     }   /* End of function IMG_Colorize() */
1602 ...     /* ====================================================================== */
1603 ... 
1604 ...     /* ====================================================================== */
1605 ...     /**
1606 ...      *  Effectue une rotation sur une image donnée
1607 ...      *  DO NOT USE SO FAR
1608 ...      */
1609 ...     /* ====================================================================== */
1610 ...     function IMG_Rotate( $img,$imgPath, $suffix, $degrees, $quality, $save)
1611 ...     /*--------------------------------------------------------------------*/
1612 ...     {
1613 ...         // Open the original image.
1614 ...         $original = imagecreatefromjpeg("$imgPath/$img") or die("Error Opening original");
1615 ...         list($width, $height, $type, $attr) = getimagesize("$imgPath/$img");
1616 ... 
1617 ...         // Resample the image.
1618 ...         $tempImg = imagecreatetruecolor($width, $height) or die("Cant create temp image");
1619 ...         imagecopyresized($tempImg, $original, 0, 0, 0, 0, $width, $height, $width, $height) or die("Cant resize copy");
1620 ... 
1621 ...         // Rotate the image.
1622 ...         $rotate = imagerotate($original, $degrees, 0);
1623 ... 
1624 ...         // Save.
1625 ...         if($save)
1626 ...         {
1627 ...             // Create the new file name.
1628 ...         $newNameE = explode(".", $img);
1629 ...         $newName = ?. $newNameE[0] .?. $suffix .?.?. $newNameE[1] .?;
1630 ... 
1631 ...         // Save the image.
1632 ...         imagejpeg($rotate, "$imgPath/$newName", $quality) or die("Cant save image");
1633 ...         }
1634 ... 
1635 ...         // Clean up.
1636 ...         imagedestroy($original);
1637 ...         imagedestroy($tempImg);
1638 ...         return true;
1639 ...     }
1640 ...     /* ====================================================================== */
1641 ... 
1642 ...     /* ====================================================================== */
1643 ...     // DO NOT USE SO FAR
1644 ...     function IMG_Reduce($img, $imgPath, $suffix, $quality)
1645 ...     /*--------------------------------------------------*/
1646 ...     {
1647 ...         // Open the original image.
1648 ...         $original = imagecreatefromjpeg("$imgPath/$img") or die("Error Opening original (<em>$imgPath/$img</em>)");
1649 ...         list($width, $height, $type, $attr) = getimagesize("$imgPath/$img");
1650 ... 
1651 ...         // Resample the image.
1652 ...         $tempImg = imagecreatetruecolor($width, $height) or die("Cant create temp image");
1653 ...         imagecopyresized($tempImg, $original, 0, 0, 0, 0, $width, $height, $width, $height) or die("Cant resize copy");
1654 ... 
1655 ...         // Create the new file name.
1656 ...         $newNameE = explode(".", $img);
1657 ...         $newName = ?. $newNameE[0] .?. $suffix .?.?. $newNameE[1] .?;
1658 ... 
1659 ...         // Save the image.
1660 ...         imagejpeg($tempImg, "$imgPath/$newName", $quality) or die("Cant save image");
1661 ... 
1662 ...         // Clean up.
1663 ...         imagedestroy($original);
1664 ...         imagedestroy($tempImg);
1665 ...         return true;
1666 ...     }
1667 ... 
1668 ... /* Le code qui suit doit permettre de créer un blur sur une image */
1669 ... //// Tiré de http://www.gamedev.net/reference/programming/features/imageproc/page2.asp
1670 ... //$coeffs = array (
1671 ... //				array ( 1),
1672 ... //				array ( 1, 1),
1673 ... //				array ( 1, 2, 1),
1674 ... //				array ( 1, 3, 3, 1),
1675 ... //				array ( 1, 4, 6, 4, 1),
1676 ... //				array ( 1, 5, 10, 10, 5, 1),
1677 ... //				array ( 1, 6, 15, 20, 15, 6, 1),
1678 ... //				array ( 1, 7, 21, 35, 35, 21, 7, 1),
1679 ... //				array ( 1, 8, 28, 56, 70, 56, 28, 8, 1),
1680 ... //				array ( 1, 9, 36, 84, 126, 126, 84, 36, 9, 1),
1681 ... //				array ( 1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1),
1682 ... //				array ( 1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1)
1683 ... //				);
1684 ... //if (!isset($_GET['img'])) die('missing img parameter');
1685 ... //if (!isset($_GET['index'])) die('missing index parameter');
1686 ... //if ($_GET['index']<0 || $_GET['index']>11) die ('index 0..11 only !');
1687 ... //if (strstr('http://', $_GET['img'])) die('Only for internal use');
1688 ... //
1689 ... //$src = array();
1690 ... //$src['index'] = $_GET['index'];
1691 ... //$src['sum'] = pow (2, $src['index']);
1692 ... //// On vérifie l'existence de l'image
1693 ... //$src['file'] = $_GET['img'];
1694 ... //if (!file_exists($src['file'])) die('Image does not exist');
1695 ... //
1696 ... //// On cherche l'image en cache
1697 ... //$src['cache_file'] = "./cache/blur".md5($src['file'].$src['index']);
1698 ... //if (file_exists($src['cache_file']) &&
1699 ... //    (intval(filemtime($src['file'])) < intval(filemtime($src['cache_file']))) &&
1700 ... //    filesize($src['cache_file'])) {
1701 ... //    // Si on a l'image traitée en cache
1702 ... //    // Et que l'image source n'est pas plus récente que celle en cache
1703 ... //    // on l'envoie !
1704 ... //	header ("Content-Type: image/png");
1705 ... //    readfile($src['cache_file']);
1706 ... //    exit();
1707 ... //}
1708 ... //// Sinon on continue le traitement
1709 ... //touch($src['cache_file']);
1710 ... //
1711 ... //// On se procure les infos sur l'image (taille/type mime)
1712 ... //$src['infos'] = getimagesize($src['file']);
1713 ... //
1714 ... //// On charge l'image de départ en fonction de son type
1715 ... //switch($src['infos']['mime']) {
1716 ... //    case 'image/jpg':
1717 ... //    case 'image/jpeg':
1718 ... //        $src['img'] = imagecreatefromjpeg($src['file']);
1719 ... //        break;
1720 ... //    case 'image/gif':
1721 ... //        $src['img'] = imagecreatefromgif($src['file']);
1722 ... //        break;
1723 ... //    case 'image/png':
1724 ... //        $src['img'] = imagecreatefrompng($src['file']);
1725 ... //        break;
1726 ... //    default:
1727 ... //        exit();
1728 ... //}
1729 ... //
1730 ... //$src['temp1'] = imagecreatetruecolor ($src['infos'][0], $src['infos'][1]);
1731 ... //$src['temp2'] = imagecreatetruecolor ($src['infos'][0], $src['infos'][1]);
1732 ... //// Traitement
1733 ... //for ( $i=0 ; $i < $src['infos'][0] ; ++$i ) {
1734 ... //	for ( $j=0 ; $j < $src['infos'][1] ; ++$j ) {
1735 ... //		$sumr=0;
1736 ... //		$sumg=0;
1737 ... //		$sumb=0;
1738 ... //		for ( $k=0 ; $k <= $src['index'] ; ++$k ) {
1739 ... //			$color = imagecolorat($src['img'], $i-(($src['index'])/2)+$k, $j);
1740 ... //			$r = ($color >> 16) & 0xFF;
1741 ... //			$g = ($color >> 8) & 0xFF;
1742 ... //			$b = ($color) & 0xFF;
1743 ... //			$sumr += $r*$coeffs[$src['index']][$k];
1744 ... //			$sumg += $g*$coeffs[$src['index']][$k];
1745 ... //			$sumb += $b*$coeffs[$src['index']][$k];
1746 ... //
1747 ... //		}
1748 ... //		$color = imagecolorallocate ($src['temp1'], $sumr/$src['sum'], $sumg/$src['sum'], $sumb/$src['sum'] );
1749 ... //		imagesetpixel($src['temp1'],$i,$j,$color);
1750 ... //	}
1751 ... //}
1752 ... //imagedestroy($src['img']);
1753 ... //
1754 ... //for ( $i=0 ; $i < $src['infos'][0] ; ++$i ) {
1755 ... //	for ( $j=0 ; $j < $src['infos'][1] ; ++$j ) {
1756 ... //		$sumr=0;
1757 ... //		$sumg=0;
1758 ... //		$sumb=0;
1759 ... //		for ( $k=0 ; $k <= $src['index'] ; ++$k ) {
1760 ... //			$color=imagecolorat($src['temp1'], $i, $j-(($src['index'])/2)+$k);
1761 ... //			$r=($color >> 16) & 0xFF;
1762 ... //			$g=($color >> 8) & 0xFF;
1763 ... //			$b=($color) & 0xFF;
1764 ... //			$sumr += $r*$coeffs[$src['index']][$k];
1765 ... //			$sumg += $g*$coeffs[$src['index']][$k];
1766 ... //			$sumb += $b*$coeffs[$src['index']][$k];
1767 ... //
1768 ... //		}
1769 ... //		$color = imagecolorallocate ($src['temp2'], $sumr/$src['sum'], $sumg/$src['sum'], $sumb/$src['sum'] );
1770 ... //		imagesetpixel($src['temp2'],$i,$j,$color);
1771 ... //	}
1772 ... //}
1773 ... //imagedestroy($src['temp1']);
1774 ... //
1775 ... //header("Content-Type: image/png");
1776 ... //imagepng($src['temp2'], $src['cache_file']);
1777 ... //imagedestroy($src['temp2']);
1778 ... //readfile($src['cache_file']);
1779 ... 
1780 ... 
1781 ... 
1782 ... /* Autre code pour le blur */
1783 ... //function blur (&$image) {
1784 ... //    $imagex = imagesx($image);
1785 ... //    $imagey = imagesy($image);
1786 ... //    $dist = 1;
1787 ... //
1788 ... //    for ($x = 0; $x < $imagex; ++$x) {
1789 ... //        for ($y = 0; $y < $imagey; ++$y) {
1790 ... //            $newr = 0;
1791 ... //            $newg = 0;
1792 ... //            $newb = 0;
1793 ... //
1794 ... //            $colours = array();
1795 ... //            $thiscol = imagecolorat($image, $x, $y);
1796 ... //
1797 ... //            for ($k = $x - $dist; $k <= $x + $dist; ++$k) {
1798 ... //                for ($l = $y - $dist; $l <= $y + $dist; ++$l) {
1799 ... //                    if ($k < 0) { $colours[] = $thiscol; continue; }
1800 ... //                    if ($k >= $imagex) { $colours[] = $thiscol; continue; }
1801 ... //                    if ($l < 0) { $colours[] = $thiscol; continue; }
1802 ... //                    if ($l >= $imagey) { $colours[] = $thiscol; continue; }
1803 ... //                    $colours[] = imagecolorat($image, $k, $l);
1804 ... //                }
1805 ... //            }
1806 ... //
1807 ... //            foreach($colours as $colour) {
1808 ... //                $newr += ($colour >> 16) & 0xFF;
1809 ... //                $newg += ($colour >> 8) & 0xFF;
1810 ... //                $newb += $colour & 0xFF;
1811 ... //            }
1812 ... //
1813 ... //            $numelements = count($colours);
1814 ... //            $newr /= $numelements;
1815 ... //            $newg /= $numelements;
1816 ... //            $newb /= $numelements;
1817 ... //
1818 ... //            $newcol = imagecolorallocate($image, $newr, $newg, $newb);
1819 ... //            imagesetpixel($image, $x, $y, $newcol);
1820 ... //        }
1821 ... //    }
1822 ... //}
1823 ... 
1824 ... /* ====================================================================== */
1825 ... /** {{*IMG_OpenImage( $szImg,$szType )=
1826 ... 
1827 ...     Determines the average color of an image. Useful to categorize
1828 ...     images based on the prominent color.
1829 ... 
1830 ...     {*params
1831 ...         $szImg      (string)    Image file
1832 ...         $szType     (string)    Optional image type. If passed, it will
1833 ...                                 be updated upon return (by reference)
1834 ...     *}
1835 ... 
1836 ...     {*return
1837 ...         (resource)  An image resource
1838 ...     *}
1839 ... 
1840 ...     {*version
1841 ...         1.0.0005
1842 ...     *}
1843 ... 
1844 ...     {*mdate
1845 ...         30/06/2013 17:58
1846 ...     *}
1847 ... 
1848 ...     {*alias
1849 ...         OpenImage(), IMG_Open()
1850 ...     *}
1851 ... 
1852 ...     *}}
1853 ...  */
1854 ... /* ====================================================================== */
1855 ... function IMG_OpenImage( $szImg,&$szType = null )
1856 ... /*--------------------------------------------*/
1857 ... {
1858 ...     if ( is_null( $szType ) || strlen( $szType ) == 0 )             /* If image type not passed */
1859 ...     {
1860 ...         $aInfo = pathinfo( $szImg ); $szType = $aInfo['extension']; /* Obtain file extension */
1861 ...     }   /* if ( is_null( $szType ) ) */
1862 ... 
1863 ...     switch ( $szType )                                              /* Open the image file in function of its extension */
1864 ...     {
1865 ...         case 'gif'  : $img = @imagecreatefromgif( $szImg );         /* Create a new image resource from a GIF file */
1866 ...                       break;
1867 ...         case 'png'  : $img = @imagecreatefrompng( $szImg );         /* Create a new image resource from a PNG file */
1868 ...                       break;
1869 ...         case 'jpg'  :
1870 ...         case 'jpeg' :
1871 ...         default     : $img = @imagecreatefromjpeg( $szImg );        /* Create a new image resource from a JPG file */
1872 ...     }   /* switch ( $szType ) */
1873 ... 
1874 ...     return ( $img );                                                /* Return image resource to caller or false if failure */
1875 ... }   /* End of function OpenImage() */
1876 ... /* ====================================================================== */
1877 ... function IMG_Open( $szImg,&$szType = null )  { return ( IMG_OpenImage( $szImg,$szType ) ); }
1878 ... function OpenImage( $szImg,&$szType = null ) { return ( IMG_OpenImage( $szImg,$szType ) ); }
1879 ... 
1880 ...     /* ====================================================================== */
1881 ...     /**
1882 ...      *  Sauve une ressource image dans un fichier de type spécifique
1883 ...      *  @param      string      $img        La ressource image à sauver
1884 ...      *  @param      string      $szTarget   Le fichier dans lequel la ressource
1885 ...      *                                      doit être sauvée.
1886 ...      *  @param      string      $szType     Type de fichier de sortie ('gif',
1887 ...      *                                      'png' ou 'jpg') pour $szTarget.
1888 ...      *  @param      int         $iQuality   Qualité de l'image de sortie (pour
1889 ...      *                                      le type .jpg)
1890 ...      *  @return     bool                    vrai (true) si l'image a été sauvée
1891 ...      *                                      dans le fichier; faux (false) dans
1892 ...      *                                      le cas contraire.
1893 ...      */
1894 ...      /* ====================================================================== */
1895 ...     function SaveImage( $img,$szTarget,$szType = 'jpg',$iQuality = 75 )
1896 ...     /*---------------------------------------------------------------*/
1897 ...     {
1898 ...         $bRetVal = false;                                               /* Ready to return a ogical false */
1899 ... 
1900 ...         switch ( $szType )                                              /* In function of the image type */
1901 ...         {
1902 ...             case 'gif' :  $bRetVal = @imagegif( $img,$szTarget );       /* Save the new image to a GIF file */
1903 ...                           break;
1904 ...             case 'png'  : $bRetVal = @imagepng( $img,$szTarget );       /* Save the new image to a PNG file */
1905 ...                           break;
1906 ...             case 'jpg'  :
1907 ...             case 'jpeg' :
1908 ...             default     : $bRetVal = @imagejpeg( $img,$szTarget,$iQuality );/* Save the new image to a JPG file */
1909 ...         }   /* switch ( $szType ) */
1910 ... 
1911 ...         return ( $bRetVal );                                            /* Return result to caller */
1912 ...     }   /* End of function SaveImage() */
1913 ...     /* ====================================================================== */
1914 ... 
1915 ...     /* ====================================================================== */
1916 ...     /**
1917 ...      *  Détermine la taille d'une image
1918 ...      *  @param      string      $szImg      Fichier qui contient l'image dont il
1919 ...      *                                      faut déterminer la largeur et la
1920 ...      *                                      hauteur
1921 ...      *  @param      int         $iWidth     Largeur de l'image. Mis à jour en
1922 ...      *                                      sortie.
1923 ...      *  @param      int         $iHeight    hauteur de l'image. Mis à jour en
1924 ...      *                                      sortie.
1925 ...      *  @return     bool                    vrai (true) si la largeur et la
1926 ...      *                                      hauteur ont pu être déterminés;
1927 ...      *                                      faux (false) dans le cas contraire
1928 ...      */
1929 ...     /* ====================================================================== */
1930 ...     function ImageSize( $szImg,&$iWidth,&$iHeight )
1931 ...     /*-------------------------------------------*/
1932 ...     {
1933 ...         $bRetVal = true;                                                /* Ready to return a logical false */
1934 ... 
1935 ...         if ( FIL_Exists( $szImg ) )                                 /* If image can be found */
1936 ...         {
1937 ...             $aInfo   = getimagesize( $szImg );                              /* Obtain image size */
1938 ...     
1939 ...             if ( $aInfo )                                                   /* If getimagesize() successful */
1940 ...             {
1941 ...                 $iWidth  = $aInfo[0];                                       /* Image width */
1942 ...                 $iHeight = $aInfo[1];                                       /* Image height */
1943 ...                 $bRetVal = true;                                            /* Ready to return a logical true */
1944 ...             }  /* if ( $aInfo ) */
1945 ...         }
1946 ... 
1947 ...         return ( $bRetVal );                                            /* Return result to caller */
1948 ...     }   /* End of function ImageSize() */
1949 ...     /* ====================================================================== */
1950 ... 
1951 ... ?>
1952 ... 

Manifest Constants

LSImages: Define "LS" Images (Pat Was Here)

VAESOLI_PATH: Define the path where Vae Soli! is installed

VAESOLI_PLUGINS: Define the path where plugins are located

UltraEdit Syntax files

  1. UltraEdit keywords of LSImages.functions.php
  2. UltraEdit Syntax of LSImages.functions.php

Function List (TOC)

  1. IMG_AverageColor(): Determines the average color of an image. Useful to categorize images based on the prominent color. No assertion found for IMG_AverageColor() (0 - 0)
  2. IMG_BlueChannel(): Keeps the red channel only No assertion found for IMG_BlueChannel() (0 - 0)
  3. IMG_Brightness(): Modify image luminosity (brightness) No assertion found for IMG_Brightness() (0 - 0)
  4. IMG_Channel(): Keeps the specified channel No assertion found for IMG_Channel() (0 - 0)
  5. IMG_Fog(): Creates a fog effect No assertion found for IMG_Fog() (0 - 0)
  6. IMG_GreenChannel(): Keeps the green channel only No assertion found for IMG_GreenChannel() (0 - 0)
  7. IMG_Hue(): Modify the image hue No assertion found for IMG_Hue() (0 - 0)
  8. IMG_Negate(): Invert image (negate) No assertion found for IMG_Negate() (0 - 0)
  9. IMG_OpenImage(): Determines the average color of an image. Useful to categorize images based on the prominent color. No assertion found for IMG_OpenImage() (0 - 0)
  10. IMG_RedChannel(): Keeps the red channel only No assertion found for IMG_RedChannel() (0 - 0)
  11. IMG_Saturation(): Modify the image saturation No assertion found for IMG_Saturation() (0 - 0)
  12. IMG_SaveAs(): Saves an image in another format No assertion found for IMG_SaveAs() (0 - 0)

Functions of LSImages.functions.php

IMG_AverageColor(): Determines the average color of an image. Useful to categorize images based on the prominent color.

[ back to function list ]

Since version 1.0.0005

Modified: 30/06/2013 17:50

Syntax

IMG_AverageColor( $szImg,$aRect )

Parameters
NameTypeDescription
$szImg string Image file
$aRect array Optional rectangle to consider
Return

(array) An associative array depicting RGB values: $aColor['r']
$aColor['g']
$aColor['b']

Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

See Also

IMG_Save()

IMG_BlueChannel(): Keeps the red channel only

[ back to function list ]

Since version 1.0.0005

Credits

Octavia Andreea Anghel

Docs

Syntax

IMG_BlueChannel( $szImg,$szTarget,$iQuality )

Parameters
NameTypeDescription
$szImg string Image to be processed
$szTarget string Image to be saved
$iQuality int Optional quality required when saving the image. 75 by default. Applies to .jpg images only.
Return

(bool) true if image treated and saved successfully; false if not

Example(s)
$szImgSrc  = "c:\\websites\\mon-site\\images\\jeu-eau.jpg";

$szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-bis.jpg";
IMG_RedChannel( $szImgSrc,$szImgDest,95 );

$szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-ter.jpg";
IMG_GreenChannel( $szImgSrc,$szImgDest,95 );

$szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-quater.jpg";
IMG_BlueChannel( $szImgSrc,$szImgDest,95 );
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

See Also

IMG_GreenChannel(), IMG_RedChannel(), IMG_Channel()

IMG_Brightness(): Modify image luminosity (brightness)

[ back to function list ]

Since version 1.0.0005

Credits

Octavia Andreea Anghel

Docs

Syntax

IMG_Brightness( $szImg,$szTarget,$fBright,$iQuality )

Parameters
NameTypeDescription
$szImg string Image to be processed
$szTarget string Image to be saved
$fBright float Optional brightness (a value between 0 and 1); 0.5 by default.
$iQuality int Optional quality required when saving the image. 75 by default.
Parameters Warning

IMG_Brightness() uses 4 parameters whereas the suggested limit is 3.

Return

(bool) true if image treated and saved successfully; false if not

Example(s)
$szSrc  = "c:\\images\\transform\\continent.jpg";
$szDest = "c:\\images\\transform\\continent-dark.jpg";

if ( ! FIL_Exists( $szDest ) )
{
    IMG_Brightness( $szSrc,$szDest,0.2,90 );
}
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

See Also

IMG_Saturation(), IMG_Hue()

IMG_Channel(): Keeps the specified channel

[ back to function list ]

Since version 1.0.0005

Credits

Octavia Andreea Anghel

Docs

Syntax

IMG_Channel( $img,$szChannel )

Parameters
NameTypeDescription
$img resource Image resource
$szChannel string Channel to keep (r, g, b)
Return

(void) The function returns no value

Example(s)
$szImg      = "c:\\websites\\mon-site\\images\\jeu-eau.jpg";
$szDest     = "c:\\websites\\mon-site\\images\\jeu-eau-bis.jpg";
$szType     = '';                                // Image type ('gif', 'png', 'jpg' ...)
$img        = OpenImage( $szImg,$szType );       // Open image

if ( $img )                                      // If 'image resource' successfully created
{
    $iQuality   = 80;                            // 0 <= JPG quality <= 100
    IMG_Channel( $img,'r' );                     // Change the red channel
    SaveImage( $img,$szDest,$szType,$iQuality ); // Save image
    imagedestroy( $img );                        // Releases all the memory associated with the image
}
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

See Also

IMG_RedChannel(), IMG_GreenChannel(), IMG_BlueChannel()

IMG_Fog(): Creates a fog effect

[ back to function list ]

Since version 1.0.0005

Credits

Octavia Andreea Anghel

Warning

Only with .png images

Docs

Syntax

IMG_Fog( $szImg,$szTarget,$iTransparency,$aRect )

Parameters
NameTypeDescription
$szImg string Image to be processed
$szTarget string Image to be saved
$iTransparency int Optional transparency value (fog effect). 63 by default. Value between 0 (full opacity) and 127 (full transparency)
$aRect array Optional rectangle. null by default
$aRect[0] = Start x
$aRect[1] = Start y
$aRect[2] = End x
$aRect[3] = End y
Parameters Warning

IMG_Fog() uses 4 parameters whereas the suggested limit is 3.

Return

(bool) true if image treated and saved successfully; false if not

Example(s)
$szSrc  = "c:\\images\\transform\\continent.png";
$szDest = "c:\\images\\transform\\continent-fog.png";

if ( ! FIL_Exists( $szDest ) )
{
    IMG_Hue( $szSrc,$szDest );
}
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

See Also

IMG_Brightness()

IMG_GreenChannel(): Keeps the green channel only

[ back to function list ]

Since version 1.0.0005

Credits

Octavia Andreea Anghel

Docs

Syntax

IMG_GreenChannel( $szImg,$szTarget,$iQuality )

Parameters
NameTypeDescription
$szImg string Image to be processed
$szTarget string Image to be saved
$iQuality int Optional quality required when saving the image. 75 by default. Applies to .jpg images only.
Return

(bool) true if image treated and saved successfully; false if not

Example(s)
$szImgSrc  = "c:\\websites\\mon-site\\images\\jeu-eau.jpg";

$szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-bis.jpg";
IMG_RedChannel( $szImgSrc,$szImgDest,95 );

$szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-ter.jpg";
IMG_GreenChannel( $szImgSrc,$szImgDest,95 );

$szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-quater.jpg";
IMG_BlueChannel( $szImgSrc,$szImgDest,95 );
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

See Also

IMG_RedChannel(), IMG_BlueChannel(), IMG_Channel()

IMG_Hue(): Modify the image hue

[ back to function list ]

Since version 1.0.0005

Credits

Octavia Andreea Anghel

Docs

Syntax

IMG_Hue( $szImg,$szTarget,$iHue,$iQuality,$aRect )

Parameters
NameTypeDescription
$szImg string Image to be processed
$szTarget string Image to be saved
$iHue int Hue variation degree (a value between 0 to 360). Default value = 30
$iQuality int Optional quality required when saving the image. 75 by default.
$aRect array Optional rectangle. null by default
$aRect[0] = Start x
$aRect[1] = Start y
$aRect[2] = End x
$aRect[3] = End y
Parameters Warning

IMG_Hue() uses 5 parameters whereas the suggested limit is 3.

Return

(bool) true if image treated and saved successfully; false if not

Example(s)
$szSrc  = "c:\\images\\transform\\continent.jpg";
$szDest = "c:\\images\\transform\\continent-85-degree.jpg";

if ( ! FIL_Exists( $szDest ) )
{
    IMG_Hue( $szSrc,$szDest,85,90 );
}
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

See Also

IMG_Brightness(), IMG_Saturation()

IMG_Negate(): Invert image (negate)

[ back to function list ]

Since version 1.0.0005

Credits

Octavia Andreea Anghel

Docs

Syntax

IMG_Negate( $szImg,$szTarget,$iQuality,$aRect )

Alias

IMG_Invert()

Parameters
NameTypeDescription
$szImg string Image to be processed
$szTarget string Image to be saved
$iQuality int Optional quality required when saving the image. 75 by default (for .jpg images)
$aRect array Optional rectangle. null by default
$aRect[0] = Start x
$aRect[1] = Start y
$aRect[2] = End x
$aRect[3] = End y
Parameters Warning

IMG_Negate() uses 4 parameters whereas the suggested limit is 3.

Return

(bool) true if image treated and saved successfully; false if not

Example(s)
$szSrc  = "c:\\images\\transform\\continent.jpg";
$szDest = "c:\\images\\transform\\continent-negate.jpg";

if ( ! FIL_Exists( $szDest ) )
{
    IMG_Negate( $szSrc,$szDest,$iQuality = 75 );
}
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

IMG_OpenImage(): Determines the average color of an image. Useful to categorize images based on the prominent color.

[ back to function list ]

Since version 1.0.0005

Modified: 30/06/2013 17:58

Syntax

IMG_OpenImage( $szImg,$szType )

Alias

OpenImage(), IMG_Open()

Parameters
NameTypeDescription
$szImg string Image file
$szType string Optional image type. If passed, it will be updated upon return (by reference)
Return

(resource) An image resource

Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

IMG_RedChannel(): Keeps the red channel only

[ back to function list ]

Since version 1.0.0005

Credits

Octavia Andreea Anghel

Docs

Syntax

IMG_RedChannel( $szImg,$szTarget,$iQuality )

Parameters
NameTypeDescription
$szImg string Image to be processed
$szTarget string Image to be saved
$iQuality int Optional quality required when saving the image. 75 by default. Applies to .jpg images only.
Return

(bool) true if image treated and saved successfully; false if not

Example(s)
$szImgSrc  = "c:\\websites\\mon-site\\images\\jeu-eau.jpg";

$szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-bis.jpg";
IMG_RedChannel( $szImgSrc,$szImgDest,95 );

$szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-ter.jpg";
IMG_GreenChannel( $szImgSrc,$szImgDest,95 );

$szImgDest = "c:\\websites\\mon-site\\images\\jeu-eau-quater.jpg";
IMG_BlueChannel( $szImgSrc,$szImgDest,95 );
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

See Also

IMG_GreenChannel(), IMG_BlueChannel(), IMG_Channel()

IMG_Saturation(): Modify the image saturation

[ back to function list ]

Since version 1.0.0005

Credits

Octavia Andreea Anghel

Docs

Syntax

IMG_Saturation( $szImg,$szTarget,$fSat,$iQuality,$aRect )

Parameters
NameTypeDescription
$szImg string Image to be processed
$szTarget string Image to be saved
$fSat float Optional saturation level (a value between 0 and 1)
0 = no color (only grey levels)
1 = full color saturation.
$iQuality int Optional quality required when saving the image. 75 by default.
$aRect array Optional rectangle. null by default
$aRect[0] = Start x
$aRect[1] = Start y
$aRect[2] = End x
$aRect[3] = End y
Parameters Warning

IMG_Saturation() uses 5 parameters whereas the suggested limit is 3.

Return

(bool) true if image treated and saved successfully; false if not

Example(s)
$szSrc  = "c:\\images\\transform\\continent.jpg";
$szDest = "c:\\images\\transform\\continent-high-saturation.jpg";

if ( ! FIL_Exists( $szDest ) )
{
    IMG_Saturation( $szSrc,$szDest,1.0,95 );
}
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

See Also

IMG_Brightness(), IMG_Hue()

IMG_SaveAs(): Saves an image in another format

[ back to function list ]

Since version 1.0.0005

Modified: 30/06/2013 17:50

Syntax

IMG_SaveAs( $szImg,$szTarget,$szType,$iQuality )

Parameters
NameTypeDescription
$szImg string Image to be processed
$szTarget string Target filename
$szType string Image type
$iQuality int Optional quality required when saving the image. 75 by default. Applies to .jpg images only.
Parameters Warning

IMG_SaveAs() uses 4 parameters whereas the suggested limit is 3.

Return

(bool) true if image saved successfully; false if not

Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

See Also

IMG_Save()

Précédent Suivant