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 winksmiley.jpg
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 6)
mls
post
Post #2





Grupa: Zarejestrowani
Postów: 677
Pomógł: 89
Dołączył: 31.08.2003
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Skrypt wywołuje jedną z funkcji imagetyp_pliku.
Spróbuj podmienić linię 113 na:
  1. <?php
  2. call_user_func(&#092;"image\".$types[$imagedata[2]], $thumb, $cachedir.$thumbfile, ($imagedata[2] == 2 ? 100 : null));
  3. ?>

Oczywiście zamiast 100 możesz podstawić inną wartość.
Uprzedzam, że nie sprawdzałem, czy to działa...


--------------------
Go to the top of the page
+Quote Post
-Guest-
post
Post #3





Goście







ale linia 113 to jest warunek else
to mam go zlikwidowac?
Czy tez napisac to w awrunku czy tez nad nim?
Go to the top of the page
+Quote Post
-blitz-
post
Post #4





Goście







Nie wiem czy dobrze ale zastapilem ten fragment

  1. <?php
  2. $image = call_user_func(&#092;"imagecreatefrom\".$types[$imagedata[2]], $image);
  3. ?>


tym
  1. <?php
  2.  $image = call_user_func(&#092;"image\".$types[$imagedata[2]], $thumb, $cachedir.$thumbfile, ($imagedata[2] == 2 ? 100 : null));
  3. ?>


efektem jest wygenerowanie miniaturki, ktora jest niestety cala czarna..


Co moze byc nie tak?
Go to the top of the page
+Quote Post
-Guest-
post
Post #5





Goście







spoko
wstawielm nie tu gdzie trzeba
Teraz jest ok

wielkie dzieki!!!!!!
Podaj adres to wysle skrzynke piwa aarambo.gif
Go to the top of the page
+Quote Post
a79rtur
post
Post #6





Grupa: Zarejestrowani
Postów: 331
Pomógł: 1
Dołączył: 23.05.2004
Skąd: Tarnów/Londyn

Ostrzeżenie: (0%)
-----


moglbys wrzucic caly popraeiony skrypt? bo u mnie dalej czarna miniaturka w cachedir


--------------------
php 5.1.2 & Apache 2.0.50 & MySQL 4.1.7 @ WinXP Pro
..:: GG 6449856 ::..
www.londyn.me.uk - ogłoszenia mieszkaniowe dla Londynu
Go to the top of the page
+Quote Post
bastek8989
post
Post #7





Grupa: Zarejestrowani
Postów: 205
Pomógł: 1
Dołączył: 11.09.2006

Ostrzeżenie: (0%)
-----


czy ten skrypcik robi thumba nawet flashowi?questionmark.gif?


--------------------
Web-Anatomy.com - tworzenie serwisów internetowych oraz stron www z okolic Bielska-Białej. Zapraszam.
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 22.08.2025 - 02:05