imagick

How can I wrap text using Imagick in PHP so that it is drawn as multiline text?

牧云@^-^@ 提交于 2019-11-27 20:54:36
The Imagick library in PHP allows you to draw text on top of an image. How can I tell Imagick to wrap the text based upon some bounded text box, so that the words appear as multiline text rather than a single line? Usage: list($lines, $lineHeight) = wordWrapAnnotation($image, $draw, $msg, 140); for($i = 0; $i < count($lines); $i++) $image->annotateImage($draw, $xpos, $ypos + $i*$lineHeight, 0, $lines[$i]); Function: /* Implement word wrapping... Ughhh... why is this NOT done for me!!! OK... I know the algorithm sucks at efficiency, but it's for short messages, okay? Make sure to set the font

php imagick convert PNG to jpg

心已入冬 提交于 2019-11-27 20:48:12
问题 $image = "[...]"; //binary string containing PNG image $file = fopen('image.tmp', 'wb'); fputs($file, $image); fclose($file); $image = new Imagick('PNG:image.tmp'); $image->thumbnailImage($width, $height); $image->setImageFormat('jpg'); $image->setCompressionQuality(97); $image->writeImage('image.jpg'); The above doesn't work and gives me a black image for this image. When doing instead [...] $image->setImageFormat('png'); $image->setCompressionQuality(97); $image->writeImage('image.png');

How to create a large (High Quality 300dpi) image from JSON / array of Data (width,height,x,y,angels) using PHP ImageMagic / Imagick

半世苍凉 提交于 2019-11-27 20:41:02
问题 I created a design (270x470) with some pictures and text on Canvas using FabricJs then i export all pictures/text information in JSON format by fabricJS's canvas.toJSON() method And Now i need to Re-Draw that design on a High Quality (2790x4560) image in PHP using Imagick. JSON dataArray for above design which contains all object's information like size,position,angle etc.. { "width": "2790", "height": "4560", "json_data": { "objects": [{ "type": "image", "originX": "left", "originY": "top",

Transparent to white in Imagick for PHP

不羁的心 提交于 2019-11-27 17:23:56
问题 I have a png image with a transparent background and I want to convert it to a jpg image with a white background. The code is basically this: $image = new Imagick('transparent.png'); $image->writeImage('opaque.jpg'); But that creates a black background jpg. I've been struggling with the worst documentation ever trying to find a way to convert the transparent to white to no avail. Edit : Well, I tried Marc B's idea and kind of got it to work. $image = new Imagick('transparent.png'); $white =

Using a transparent PNG as a clip mask

☆樱花仙子☆ 提交于 2019-11-27 16:26:02
问题 Is it possible to take this image: And apply this mask: And turn it into this: Using either GD or Imagick? I know it's possible to mask an image using shapes but I'm not sure how to go on about doing it with a pre-created alphatransparent image. :s 回答1: Using Imagick and ImageMagick version > 6 (I don't know if it will work on older versions): // Set image path $path = '/path/to/your/images/'; // Create new objects from png's $dude = new Imagick($path . 'dude.png'); $mask = new Imagick($path

Get/set DPI with PHP GD/Imagick?

☆樱花仙子☆ 提交于 2019-11-27 15:31:15
I'm building a Web application that will handle image files that will ultimately be printed, large format. As part of this, I need to get (i.e. read) and set (i.e. change) the DPI of an image file. Is this possible through PHP GD or PHP Imagick? Thanks, BK Edit: The DPI of a image can be accessed through iMagick's getImageResolution method: public function getDPI() { $imgDPI = $this->image->getImageResolution(); return $imgDPI; } and the DPI of an image can be set through iMagick's setImageResolution method: public function setDPI($DPIX, $DPIY) { $this->image->setImageResolution($DPIX,$DPIY);

Wrap an image around a cylindrical object in HTML5 / JavaScript

谁说胖子不能爱 提交于 2019-11-27 14:12:54
I want to wrap an image around a cylindrical object like mugs in a web app, like so This will likely be a base image (e.g. a jpeg image of a mug) containing a transformed image of a user uploaded image. There seems to be a lot of resources on this in PhotoShop . However, this is of course not appropriate for web, mobile or server environments. I also know this is possible, as a number of sites already do this extremely well. For example, Vista Print (see image), Asda Photos (and loads more on the internet by just searching personalised mugs on Google), using what seems to be just HTML5.

ImageMagick Brew installation with PHP Module in Mac OS X

旧巷老猫 提交于 2019-11-27 13:31:07
I have installed ImageMagick using brew install imagemagick . This all worked fine and I can run any ImageMagick command from the Terminal / Command line. Now when I try to use the ImageMagick classes in PHP, I get an error Class 'Imagick' not found in ... . I guess this is because the ImageMagick module is not loaded. Could anyone help me to get this thing working in PHP? Thanks! Additional info: Mac OS X Version: 10.8: Mountain Lion PHP Version : 5.3.13 Kurt Pfeifle Your ImageMagick installation is not enough. You also need the Imagick package (possibly called php72-imagick or similar for

How to stop PHP iMagick auto-rotating images based on EXIF 'orientation' data

…衆ロ難τιáo~ 提交于 2019-11-27 12:25:32
Currently working with PHP and iMagick to develop a poster printing Web application. This is the example image I am using to test upload/image editing features of the application: The image contains the following EXIF data: [FileName] => 1290599108_IMG_6783.JPG [FileDateTime] => 1290599109 [FileSize] => 4275563 [FileType] => 2 [MimeType] => image/jpeg [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF, INTEROP, MAKERNOTE [COMPUTED] => Array ( [html] => width="3504" height="2336" [Height] => 2336 [Width] => 3504 [IsColor] => 1 [ByteOrderMotorola] => 0 [CCDWidth] => 22mm [ApertureFNumber] => f/5

How to install ImageMagick to use with PHP on Windows 7 (3)

。_饼干妹妹 提交于 2019-11-27 11:43:18
There are other threads about how to install Imagick on Windows 7 but no help for me so far. :( (Maybe problems have came up with more recent versions) I have followed these steps to install: Download and install ImageMagick http://www.imagemagick.org/download/binaries/ImageMagick-6.8.8-1-Q16-x86-dll.exe Download php_imagick.dll and copy to extension dir (c:\xampp\php\ext) http://www.peewit.fr/imagick/php55/vc11/x86/ts/php_imagick.dll Edit php.ini file and add new extension (c:\xampp\php\php.ini) extension=php_imagick.dll Save ini file and restart Apache (if necessary, restart Windows) Start