Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Kompresja i obrka zdjec
-blitz!-
post
Post #1





Goście







Witam
Mam ogromna prosbe...
Pracuje nad porzygotowanie skelpu OSC (oscommerce) i zainstalowalem kontrybucje do kompresji i zmnijszania wielkosci plikow graficznych.

Mam problem poniewaz nei wiem gdize ustawic jakosc kompresji (np w przypadku jpeg na 60-70) poniewaz ta domyslna jest niska i jakosc jest do niczego.

Czy w ogole da sie to tu ustawic?

Oto caly skrypt
  1. <?php
  2.  
  3.  
  4. function thumbimage ($image, $x, $y, $aspectratio, $resize, $cachedir){
  5.  
  6. /*##############################################
  7. # - Thumbnail-Script v1.3 -  #
  8. # Generating thumbnails 'on-the-fly' with php #
  9. # #
  10. # (c) by Christian Lamine, FlashDreams OHG #
  11. # http://www.flashdreams.de/ #
  12. # #
  13. #  Modified by http://www.tse.at #
  14. #  Modified by lars@iwer.de  #
  15. # #
  16. # This script may be freely used, distributed #
  17. # and modified without any charge as long as  #
  18. # this copyright information is included. #
  19. # #
  20. # Any commercial selling of this script is  #
  21. # forbidden.  #
  22. # #
  23. # The author is not responsible for possible  #
  24. # damage which may result from the application #
  25. # of this script, neither direct nor indirect. #
  26. # Use at your own risk! #
  27. ##############################################*/
  28.  
  29.  
  30.  $types = array (1 => &#092;"gif\", \"jpeg\", \"png\", \"swf\", \"psd\", \"wbmp\");
  31.  $not_supported_formats = array (&#092;"\"); // Write in capital Letters!!
  32.  umask(0);
  33.  !is_dir ($cachedir)
  34.  ? mkdir ($cachedir, 0777)
  35.  : system (&#092;"chmod 0777 \".$cachedir);
  36.  
  37.  (!isset ($x) || ereg ('^[0-9]{1,}$', $x, $regs)) &&
  38.  (!isset ($y) || ereg ('^[0-9]{1,}$', $y, $regs)) &&
  39.  (isset ($x) || isset ($y))
  40. true
  41. : DIE ('Fehlende(r) oder ungültige(r) Größenparameter!');
  42.  
  43.  !isset ($resize) || !ereg ('^[0|1]$', $resize, $regs)
  44. $resize = 0
  45. : $resize;
  46.  
  47.  !isset ($aspectratio) || !ereg ('^[0|1]$', $aspectratio, $regs)
  48. isset ($x) && isset ($y)
  49.  ? $aspectratio = 1
  50.  : $aspectratio = 0
  51. : $aspectratio;
  52.  
  53.  !isset ($image)
  54. DIE ('Nie zadeklarowano zadnego obrazka!')
  55. : !file_exists($image)
  56.  ? DIE ('Nie mozna bylo odnalesc pliku na serwerze!')
  57.  : false;
  58.  
  59.  $imagedata = getimagesize($image);
  60.  
  61.  !$imagedata[2] || $imagedata[2] == 4 || $imagedata[2] == 5
  62. DIE ('Podczas pracy wykryto zly rodzaj pliku!')
  63. : false;
  64.  
  65.  $imgtype=&#092;"!(ImageTypes() & IMG_\" . strtoupper($types[$imagedata[2]]) . \")\";
  66.  if ((eval($imgtype)) || (in_array(strtoupper(array_pop(explode('.', basename($image)))),$not_supported_formats))) {
  67.  $image = substr ($image, (strrpos (DIR_FS_CATALOG . '/', '/'))+1);
  68.  return $image;
  69.  
  70.  }
  71.  
  72.  if (!isset ($x)) $x = floor ($y * $imagedata[0] / $imagedata[1]);
  73.  
  74.  
  75.  if (!isset ($y)) $y = floor ($x * $imagedata[1] / $imagedata[0]);
  76.  
  77.  if ($aspectratio && isset ($x) && isset ($y)) {
  78. if ((($imagedata[1]/$y) > ($imagedata[0]/$x) )){
  79.  $x=ceil(($imagedata[0]/$imagedata[1])* $y);
  80. } else {
  81.  $y=ceil($x/($imagedata[0]/$imagedata[1]));
  82. }
  83.  }
  84.  
  85.  $thumbfile = '/' . basename($image);
  86.  if (file_exists ($cachedir.$thumbfile)) {
  87. $thumbdata = getimagesize ($cachedir.$thumbfile);
  88. $thumbdata[0] == $x && $thumbdata[1] == $y
  89.  ? $iscached = true
  90.  : $iscached = false;
  91.  } else {
  92. $iscached = false;
  93.  }
  94.  
  95.  if (!$iscached) {
  96. ($imagedata[0] > $x || $imagedata[1] > $y) || (($imagedata[0] < $x || $imagedata[1] < $y) && $resize)
  97.  ? $makethumb = true
  98.  : $makethumb = false;
  99.  } else {
  100. $makethumb = false;
  101.  }
  102.  if ($makethumb) {
  103. $image = call_user_func(&#092;"imagecreatefrom\".$types[$imagedata[2]], $image);
  104. if (function_exists(&#092;"imagecreatetruecolor\") && ($thumb = imagecreatetruecolor ($x, $y))) {
  105. imagecopyresampled ($thumb, $image, 0, 0, 0, 0, $x, $y, $imagedata[0], $imagedata[1]);
  106. } else {
  107. $thumb = imagecreate ($x, $y);
  108. imagecopyresized ($thumb, $image, 0, 0, 0, 0, $x, $y, $imagedata[0], $imagedata[1]);
  109. }
  110. call_user_func(&#092;"image\".$types[$imagedata[2]], $thumb, $cachedir.$thumbfile);
  111. imagedestroy ($image);
  112. imagedestroy ($thumb);
  113. $image = DIR_WS_IMAGES . 'imagecache' . $thumbfile;
  114.  } else {
  115. $iscached
  116.  ? $image = DIR_WS_IMAGES . 'imagecache' . $thumbfile
  117.  : $image = substr ($image, (strrpos (DIR_FS_CATALOG . '/', '/'))+1);
  118.  }
  119. return $image;
  120. }
  121. ?>


Chcialem popytac na forum tworcy skryptu ale niestety moj niemiecki nie jest lepszy od opanowania j. chińskiego przez 90 % Polakow (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 15.09.2025 - 02:09