Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Problem z odczytaniem obrazka
Blastereq
post 4.07.2006, 14:42:31
Post #1





Grupa: Zarejestrowani
Postów: 42
Pomógł: 0
Dołączył: 28.11.2005

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


Używam pewnej funkcji do wczytania obrazka i potem zrobienia z niego miniaturki (imagecreatefromjpg" title="Zobacz w manualu php" target="_manual). Chcę, abym miał możliwość zapisywania obrazków z innych stron w formacie http://www.domena.pl/obrazek.jpg . O ile funkcja działa u mnie na serwerze (Krasnal) to na serwie wykupionym nie.
Próbowałem robić na serwerze :
file_exists" title="Zobacz w manualu php" target="_manual ( http://domena.pl/obrazek.jpg ) - pokazywało, że nie istnieje
fopen" title="Zobacz w manualu php" target="_manual( http://domena.pl/obrazek.jpg, wb) - HTTP wrapper does not support writeable connections.

Co tu począć ?


--------------------
śmieszne filmiki
Go to the top of the page
+Quote Post
Cysiaczek
post 4.07.2006, 14:45:20
Post #2





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Możesz pokazać kod? Z tego co napisałeś, to możliwe jest, że na serwerze nie ma biblioteki GD. Jeśli nie ma, to żaden kod nie pomoże.


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
Blastereq
post 4.07.2006, 14:48:48
Post #3





Grupa: Zarejestrowani
Postów: 42
Pomógł: 0
Dołączył: 28.11.2005

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


Sorry, że nie napisałem, ale funkcja działa, jeśli plik jest pobierny w postaci : katalog/obrazki/obrazek.jpg
GD tym samym oczywiscie też jest

Jakby to coś dało to :
  1. <?php
  2. function resize_photo($src, $dest, $maxWidth, $maxHeight, $quality = 90) {
  3.  
  4.  $destInfo = pathInfo($dest);
  5.  $srcSize = getImageSize($src);
  6.  $srcRatio = $srcSize[0]/$srcSize[1]; // width/height ratio
  7.  $destRatio = $maxWidth/$maxHeight;
  8.  if ($destRatio > $srcRatio) {
  9.  $destSize[1] = $maxHeight;
  10.  $destSize[0] = $maxHeight*$srcRatio;
  11.  }
  12.  else {
  13.  $destSize[0] = $maxWidth;
  14.  $destSize[1] = $maxWidth/$srcRatio;
  15.  }
  16.  
  17.  if ($destInfo['extension'] == "gif") {
  18.  $dest = substr_replace($dest, 'jpg', -3);
  19.  }
  20.  
  21.  
  22.  $destImage = imageCreateTrueColor($destSize[0],$destSize[1]);
  23.  imageAntiAlias($destImage,true);
  24.  
  25.  
  26.  switch ($srcSize[2]) {
  27.  case 1: //GIF
  28.  $srcImage = imageCreateFromGif($src);
  29.  break;
  30.  
  31.  case 2: //JPEG
  32.  $srcImage = imageCreateFromJpeg($src);
  33.  break;
  34.  
  35.  case 3: //PNG
  36.  $srcImage = imageCreateFromPng($src);
  37.  break;
  38.  
  39.  default:
  40.  return false;
  41.  break;
  42.  }
  43.  
  44.  
  45.  imageCopyResampled($destImage, $srcImage, 0, 0, 0, 0,$destSize[0],$destSize[1],$srcSize[0],$srcSize[1]);
  46.  
  47.  switch ($srcSize[2]) {
  48.  case 1:
  49.  case 2:
  50.  imageJpeg($destImage,$dest,$quality);
  51.  break;
  52.  
  53.  case 3:
  54.  imagePng($destImage,$dest);
  55.  break;
  56.  }
  57.  return true;
  58.  }
  59. ?>


Ten post edytował Blastereq 4.07.2006, 14:50:36


--------------------
śmieszne filmiki
Go to the top of the page
+Quote Post
Cysiaczek
post 4.07.2006, 15:47:20
Post #4





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Jeśli mówisz, że działa przy ścieżkach systemowych, to znaczy, że serwer nie obsługuje metody fopen dla http. Nie otworzysz tego pliku w ten sposób:
Kod
fopen( http://domena.pl/obrazek.jpg, wb) - HTTP wrapper does not support writeable connections.

stąd ten error - spróbuj jeszcze przez 'r', ale wątpię.


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
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 Wersja Lo-Fi Aktualny czas: 18.06.2025 - 06:21