Ja det er hele billedet der bliver sort
Så skal i da lige have hele koden at se der bliver brugt
- file_put_contents("../webshop-imgs/$filnavn",file_get_contents($pic));
- $resizeObj = new resize("../webshop-imgs/$filnavn");
- $resizeObj -> resizeImage(150, 150, 'auto');
- $resizeObj -> saveImage("../webshop-imgs/$filnavn", 100);
- public function resizeImage($newWidth, $newHeight, $option="auto") {
- $optionArray = $this->getDimensions($newWidth, $newHeight, $option);
- $optimalWidth = $optionArray['optimalWidth'];
- $optimalHeight = $optionArray['optimalHeight'];
-
- $this->imageResized = imagecreatetruecolor($optimalWidth, $optimalHeight);
- imagecopyresampled($this->imageResized, $this->image, 0, 0, 0, 0, $optimalWidth, $optimalHeight, $this->width, $this->height);
- }
- public function saveImage($savePath, $imageQuality="100")
- {
- $extension = strrchr($savePath, '.');
- $extension = strtolower($extension);
-
- switch($extension)
- {
- case '.jpg':
- case '.jpeg':
- if (imagetypes() & IMG_JPG) {
- imagejpeg($this->imageResized, $savePath, $imageQuality);
- }
- break;
-
- case '.gif':
- if (imagetypes() & IMG_GIF) {
- imagegif($this->imageResized, $savePath);
- }
- break;
-
- case '.png':
- $scaleQuality = round(($imageQuality/100) * 9);
-
- $invertScaleQuality = 9 - $scaleQuality;
-
- if (imagetypes() & IMG_PNG) {
- imagepng($this->imageResized, $savePath, $invertScaleQuality);
- }
- break;
-
- default:
- break;
- }
-
- imagedestroy($this->imageResized);
- }