imagick

PHP: Need to convert imagemagick command to php script

雨燕双飞 提交于 2019-12-24 10:36:23
问题 I use this command to batch modify images for a site. They need to be this size to suit the theme. Now I also want to use these images in Facebook Ads, but they have to be resized. The command I use (which works fine) is: for i in `ls -1 *.jpg`; do convert $i -fuzz 10% -trim +repage -resize 980x1200 -background white -gravity center -extent 980x1200 $i; done Now I need to make a PHP script that does the same, but also returns the image as response. I came up with the following: <?php /*

SVG to PNG image conversion in php

我与影子孤独终老i 提交于 2019-12-24 06:28:50
问题 I want to convert SVG images to PNG files with transparent background. I am using below code to convert it using imagick in php,but it gives image with black background. $image = new imagick(); //set transparent background $image->setBackgroundColor(new ImagickPixel('transparent')); $image->setFormat('svg'); $image->readImageBlob(file_get_contents("image.svg")); $image->setImageFormat("png32"); $image->resizeImage(265,195, Imagick::FILTER_LANCZOS, 1); $image->writeImage('result.png'); Can

SVG to PNG image conversion in php

不打扰是莪最后的温柔 提交于 2019-12-24 06:28:02
问题 I want to convert SVG images to PNG files with transparent background. I am using below code to convert it using imagick in php,but it gives image with black background. $image = new imagick(); //set transparent background $image->setBackgroundColor(new ImagickPixel('transparent')); $image->setFormat('svg'); $image->readImageBlob(file_get_contents("image.svg")); $image->setImageFormat("png32"); $image->resizeImage(265,195, Imagick::FILTER_LANCZOS, 1); $image->writeImage('result.png'); Can

PHP Imagick cannot set image background color

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 03:43:32
问题 I load transparent png image and i every time i try to set bg color using setimagebackgroundcolor() it still transparent $input_img = new Imagick(); $input_img->setBackgroundColor("#ff0000"); $input_img->readImage("transparent.png"); $input_img->setimagebackgroundcolor("#00ff00"); $input_img->setImageFormat("png"); $input_img->setimagebackgroundcolor("#ff00ff"); $input_img->writeimage("image.png"); 回答1: First line of the code sets a new Imagickpixel object for the colors. Second line creates

How to add captcha in Yii-2 application?

断了今生、忘了曾经 提交于 2019-12-23 22:58:32
问题 I'm trying to add the captcha to the login form. My environment: Yii 2 php 5.4.45 TS IIS 10.0 Windows 10 In login.php , LoginForm.php and SiteController.php I added the following (shown only the relevant parts): backend\views\site\login.php: use yii\captcha\Captcha; ... <?= $form->field($model, 'captcha')->widget(Captcha::className()) ?> ... common\models\LoginForm.php: ... public $captcha; ... public function rules() { return [ ... [['username', 'password', 'captcha'], 'required'], ['captcha

Crop bug in PHP Imagick?

寵の児 提交于 2019-12-23 19:02:05
问题 I was trying to crop the animated gif and in the output i'm getting the same sized image, but cropped. A lot of empty space is filled with canvas. For example i had animated gif 600x100, but have requested 100x100 crop, on the output i'm getting 600x100 image with cropped image and empty space. Someone knows the solution for this issue? $gif = new Imagick($s['src']); foreach($gif as $frame){ $frame->cropImage($s['params']['w'], $s['params']['h'], $s['params']['x'], $s['params']['y']); } $gif-

Imagick setColor not working with php

♀尐吖头ヾ 提交于 2019-12-23 16:35:55
问题 I've tried setting all pixels to black. But it isn't working. I am getting the same image as original. Here is my code: $image = new Imagick(__DIR__."/image_new.jpg"); $i=0; $j=0; while ($i < 100) { $j=0; while($j < 100) { $pixel = $image->getImagePixelColor($i, $j); $pixel->setColor("#000000"); $j++; } $i++; } header("content-type:image/jpeg"); echo $image; Image size is 100x100. Any ideas? 回答1: The Imagick::getImagePixelColor will return an ImagickPixel object; which, would have copied data

Incompatible library version: imagick.so requires version 18.0.0 or later, but libfreetype.6.dylib provides version 16.0.0 in Unknown on line 0

风流意气都作罢 提交于 2019-12-23 16:18:37
问题 I installed imagemagic and imagick successfully (using http://www.php.net/manual/en/imagick.installation.php#94169 steps ) and also put extension=imagick.so. but when i restart apache i am getting following error. Unable to load dynamic library /Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212/imagick.so dlopen(/Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212/imagick.so, 9): Library not loaded: /usr/local/lib/libfreetype.6.dylib

How to know if imagick throws an error - PHP

╄→尐↘猪︶ㄣ 提交于 2019-12-23 10:08:37
问题 I am currently using imagick for image processing on my webssite. I have it correctly installed and is working great. Heres my starting code -: $image = new imagick($filename); $geo=$image->getImageGeometry(); $image->setImageInterlaceScheme(2); $image->setImageCompressionQuality(85); $image->setImageBackgroundColor('white'); $image = $image->flattenImages(); $image->setImageFormat('jpg'); $image->stripImage(); After this i do the rest of the part. Now suppose it throws an error, how do i

Dynamic image creation/Apache headers using Imagick

有些话、适合烂在心里 提交于 2019-12-23 09:26:38
问题 While transferring an existing, stable, website to a new server I've run into an intermittent problem with a bit of code that creates images dynamically using Imagick. The code parses a GET query (eg example.com/image.php?ipid=750123&r=0&w=750&h=1000) and then scales and rotates an image stored on the server and serves it to the client. ipid = id for an image stored on server r = degrees of rotation w = width to display h = height to display. The code has probably been used for at least 5