Witam, mam pytanie.
Jak konwertuje się grafikę przy użyciu gd2?
Mam formularz który upload-uje plik .jpg na serwer.
I chciałbym zmiejszyć jego rozdzielczość np. do 600x400,
Mógłby ktoś pomóc, będe zobowiązany
<?php $oldWidth = $dimensions[0]; $oldHeight = $dimensions[1]; while( $oldWidth > $this->maxWidth || $oldHeight > $this->maxHeight ) { $oldWidth -= $oldWidth * 0.01; $oldHeight -= $oldHeight * 0.01; } $newWidth = $oldWidth; $newHeight = $oldHeight; $small = imagecreatetruecolor( $newWidth, $newHeight ); $source = imagecreatefromgif( $this->imagesStartDir.$fileName ); } else { $source = imagecreatefromjpeg( $this->imagesStartDir.$fileName ); } imagecopyresampled( $small, $source, 0, 0, 0, 0, (int)$newWidth, (int)$newHeight, (int)$dimensions[0], (int)$dimensions[1]); $result = imagejpeg( $small, $this->imagesDestinationDir.$smallFileName ) ; imagedestroy( $small ); ?>
<?php while( $oldWidth > $this->maxWidth || $oldHeight > $this->maxHeight ) { $oldWidth -= $oldWidth * 0.01; $oldHeight -= $oldHeight * 0.01; } ?>
<?php $newWidth = $oldWidth/$dzielnik; $newHeight = $oldHeight/$dzielnik; ?>