Git Product home page Git Product logo

imagickdemos's Introduction

Build status

Build status

🌈🌈 Imagick 🌈🌈

Imagick is a PHP extension to create and modify images using the ImageMagick library. There is also a version of Imagick available for HHVM. Although the two extensions are mostly compatible in their API, and they both call the ImageMagick library, the two extensions are completely separate code-bases.

PHP Imagick

Bugs can also be reported at https://bugs.php.net but may have a slower response time.

HHVM Imagick

Installation on Linux

The best way of installing Imagick is through a package manager e.g. apt, yum, brew, as they will also install ImageMagick for you.

If you need to compile Imagick from source, first you should install ImageMagick, at least version 6.2.4 but it is STRONGLY recommended to use a more recent version due to the many bug fixes in it.

Once ImageMagick is installed, the following commands will compile and install Imagick:

git clone https://github.com/Imagick/imagick
cd imagick
phpize && ./configure
make
make install

You will also need to add extension=imagick.so to your PHP ini file to make PHP load the extension.

Installing on Windows

For Windows please install both Imagick and the underlying ImageMagick library from:

Once compiled, Imagick should be run with the same version of ImageMagick that it was compiled against. Running against a different version of ImageMagick is known to cause stability issues, and so is not recommended or supported.

NixOS

If using Imagick on NixOS, you probably want to define FONTCONFIG_FILE to avoid a warning message when loading fonts, and MAGICK_CONFIGURE_PATH to have all the information available from Imagick::getConfigureOptions().

Examples

Almost all of the functions in the library have an example at www.phpimagick.com, where you can see the example code to call the function, as well as the generated image or output.

ImageMagick

ImageMagick, the library that the Imagick extension exposes to PHP has had many bug fixes, that have fixed many image corruption issues. We strongly recommend upgrading to the latest version (greater than 6.9.1 or 7.x) if at all possible.

Security

The PHP extension Imagick works by calling the ImageMagick library. Although the ImageMagick developers take good care in avoiding bugs it is inevitable that some bugs will be present in the code. ImageMagick also uses a lot of third party libraries to open, read and manipulate files. The writers of these libraries also take care when writing their code. However everyone makes mistakes and there will inevitably be some bugs present.

Because ImageMagick is used to process images it is feasibly possible for hackers to create images that contain invalid data to attempt to exploit these bugs. Because of this we recommend the following:

  1. Do not run Imagick in a server that is directly accessible from outside your network. It is better to either use it as a background task using something like SupervisorD or to run it in a separate server that is not directly accessible on the internet.

Doing this will make it more difficult for hackers to exploit a bug, if one should exist in the libraries that ImageMagick is using.

  1. Run it as a very low privileged process. As much as possible the files and system resources accessible to the PHP script that Imagick is being called from should be locked down.

  2. Verify that all image files begin with the expected "magic bytes" corresponding to the image file types you support before sending them to ImageMagick for processing. This an be be done with finfo_file() - see below.

  3. Check the result of the image processing is a valid image file before displaying it to the user. In the extremely unlikely event that a hacker is able to pipe arbitrary files to the output of Imagick, checking that it is an image file, and not the source code of your application that is being sent, is a sensible precaution. This can be accomplished by the following code:

<?php
	$finfo = finfo_open(FILEINFO_MIME_TYPE);
	$mimeType = finfo_file($finfo, $filename);
	
	$allowedMimeTypes = [
		'image/gif',
		'image/jpeg',
		'image/jpg',
		'image/png'
	];
	
	if (in_array($mimeType, $allowedMimeTypes) == false) {
		throw new \SecurityException("Was going to send file '$filename' to the user, but it is not an image file.");
	}
  1. NEVER directly serve any files that have been uploaded by users directly through PHP, instead either serve them through the webserver, without invoking PHP, or use readfile to serve them within PHP.

These recommendations do not guarantee any security, but they should limit your exposure to any Imagick/ImageMagick related security issue.

OpenMP

ImageMagick has the ability to use the Open Multi-Processing API to be able to use multiple threads to process an image at once. Some implementations of OpenMP are known to have stability issues when they are used in certain environments.

We recommend doing one of the following:

  • Disabling OpenMP support in ImageMagick by compiling it with the compile flag "--disable-openmp" set.

  • Disable the use of threads in ImageMagick via Imagick by calling: Imagick::setResourceLimit(\Imagick::RESOURCETYPE_THREAD, 1); or Imagick::setResourceLimit(6, 1); if your version of Imagick does not contain the RESOURCETYPE_THREAD constant.

  • Disable the use of threads in ImageMagick by setting the thread resource limit in ImageMagick' policy.xml file with <policy domain="resource" name="thread" value="1"/> This file is possibly located at /etc/ImageMagick-6/policy.xml or similar location.

  • If you do want to use OpenMP in ImageMagick when it's called through Imagick, you should test thoroughly that it behaves correctly on your server.

TODO

Documentation needs a lot of work. There is an online editor here: https://edit.php.net/ Contributions are more than welcome.

Please refer to http://abi-laboratory.pro/tracker/timeline/imagemagick/ for exact version changes of the underlying ImageMagick library.

imagickdemos's People

Contributors

danack avatar vanderlee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imagickdemos's Issues

this is not showing any output

Reported from ImagickDraw::rectangle this code is not working for me i mean whether i need modify /add anything in that code don't know so please help me to get output for that and also
how to draw nested rectangle and writing text into that inner rectangle.

Difference?

I have found an extensive tutorial for finding similar images at http://www.imagemagick.org/Usage/compare/ with a command line version of imagick but in another website the difference filter is just noted as "doesn't work".

Is that so? Do you have any resource/link for me to find info about that?
I hope I can merge this script https://www.wphub.com/44-ways-hack-wordpress-media-library/ with the one above to find similar images in wordpress (one of my scripts uploaded the same image over and over. It shows how novice I am in PHP :( Any help in the right direction would be appreciated :)

Explanation of the getColorCount function.

Hallo Danack,

at first I want to thank you for your work because I really love the way you prepared your demo page for Imagick as the php.net Docu is at many points not very helpful when talking about Imagick.
So I want to explain the getColorCount function as your comment implies you don't now what it's functionality is meant to do. Even if php.net's page for this function is saying
"Warning This function is currently not documented; only its argument list is available." it offers an example on http://php.net/manual/en/imagick.getimagehistogram.php and so you do on http://phpimagick.com/Imagick/getImageHistogram.
Looking at your example code we see

foreach ($histogramElements as $histogramElement) {
  $color = $histogramElement->getColorValue($colorChannel);
  $color = intval($color * 255);
  $count = $histogramElement->getColorCount();

  if (array_key_exists($color, $colorStatistics)) {
    $colorStatistics[$color] += $count;
  }
  else {
    $colorStatistics[$color] = $count;
  }
}

So what this function is basically doing is counting the pixels in the image with the same color code as this pixel which explains why your example code was not working as it was missing the context of an image. I think this context is a necessary condition for this function to return a meaningful result.
I hope I was able to show you the way this function works and you will be able to provide a demonstration on your side.

Greetings
Joe Pietler

Performance recommendations?

My CPU is going over 100% when a page loads and needs multiple images processed at once (10-20). I can even see it with a single image spiking to 50%. I read about MAGICK_THREAD_LIMIT and OMP_THREAD_LIMIT, but setting them didn't seem to help or may have done it wrong with the putenv function. Do you have any examples or insight into what I could do to reduce the overall CPU usage?

I know adding more horsepower or pre-processing would help, but am trying to keep it all real-time and am ok if it takes longer to load up the images.

Appreciate any thoughts.

Requesting demo

Would you be able to add a demo that softens the image after calling floodFillPaintImage? The end goal would be to strip an image of it's background. I have been able to identify the main color in an image and replace it with a transparent one or another color, but the image looks pixelated when a new background is added and has remnants of the original. A tutorial for a feathering effect would be a huge help.

Before: white background
chairs

After: gray background
552e97ed7363055f470041aa

Imagick is not working in WIMP environment for PHP-website based on Piwigo

Imagick DLL is not working in WIMP environment for PHP-website based on Piwigo
Hello,

On my webserver I have a WIMP environment running: Windows10 pro 32bit, IIS 10, MySQL and PHP websites.
I have the PHP-based website of the Piwigo platform running (= photo gallery website software which I use for digital art exposition).
To display animated GIF files, I have replaced the standard Graphics Library by ImageMagick 6.9.3-7 .
This does not work in the context of DLLs available for PHP, meaning: no generation of resized instances, such as thumbnails etc.
Even normal/still GIFs and JPGs are not processed anymore when uploaded.
Via a Command Prompt I can instruct Imagick (running as Windows software), by means of a script, to make a resized instance of the original.
I would have to do this manually for each image (50 times) and for each size specification (4x50 ?).
I do not know the script parameters for sizes other than thumbnails. Do you have script-examples of different sizes?
Do you know what to do to get the installation of Imagick running properly as the default Graphics Library within Piwigo?
Please ask me which technical information you need to solve this problem, and I will gather all relevant data for you.

Thanking you in advance, I remain.
Friendly regards,
Rolf Snijders
[email protected]


Piwigo version: 2.8.6
PHP version: 5.6.0
MySQL version: 5.5.54
WIMP platform: Windows 10 pro 32bit, IIS 10 webserver, MySql, PHP.
Piwigo URL: http://www.rolfsnijders.net/?br=gim


Example of working manual script for command prompt:
"C:/aSubdirectory/ImageMagick-7.0.5-Q16/convert" "C:/aSubdirectory/piwigo/galleries/OriginalCategories/BeautyMotives/Animations/FapTrailer8-animationToFro2-RGES.gif" -coalesce -filter Lanczos -resize 144x144! -quality 97 -sampling-factor 4:2:2 -layers OptimizePlus "C:/aSubdirectory/piwigo/_data/i/galleries/OriginalCategories/BeautyMotives/Animations/FapTrailer8-animationToFro2-RGES-th.gif"

phpimagick.com Not Working...

Hello;

i want to look the phpimagick.com for example. But the web site is not working.
Can you check the web site ?

Thank you.

Tier using DI to implement app architecture
Exception Predis\Connection\ConnectionException: 'Connection refused [tcp://127.0.0.1:6379]'

#0 /home/imagickdemos/6e60dd97003d180e1e38035833cf9e73da8343bc/vendor/predis/predis/src/Connection/StreamConnection.php 97 Predis\Connection\AbstractConnection->onConnectionError
#1 /home/imagickdemos/6e60dd97003d180e1e38035833cf9e73da8343bc/vendor/predis/predis/src/Connection/StreamConnection.php 58 Predis\Connection\StreamConnection->tcpStreamInitializer
#2 /home/imagickdemos/6e60dd97003d180e1e38035833cf9e73da8343bc/vendor/predis/predis/src/Connection/AbstractConnection.php 94 Predis\Connection\StreamConnection->createResource
#3 /home/imagickdemos/6e60dd97003d180e1e38035833cf9e73da8343bc/vendor/predis/predis/src/Connection/StreamConnection.php 158 Predis\C

compositeImage Error

Good day. I use PECL imagick on my website and have some problem with compositeImage function. I'm not sure - can I ask you about this problem? If, no - may be you can advice me where I can do this. If yes, - I have this situation:
I need add one image into another and use compositeImage for this, but result image very strange. I put my example here - http://en.allworldsms.com/test/im/test.php. This is script page with code:

newImage(700,700,new ImagickPixel('#f0f')); $pic=new Imagick('im.jpg'); $pic->thumbnailImage(500,500); $img->compositeImage($pic,imagick::COMPOSITE_DEFAULT,100,100); $img->setImageFormat("JPEG"); $img->writeImage($_SERVER["DOCUMENT_ROOT"].'/test/im/test.jpg'); $img->clear();$img->destroy(); echo '

'; ?>

source image:
source

result image
res

Tutorial about Masking

Hello,

I try to run this example on my localhost…
https://phpimagick.com/Tutorial/backgroundMasking
But I get the same picture without checkerboard.

My best working code is :

  $BackgroundColor = "rgb(255, 255, 255)";
  $img = new Imagick();
  $img->readImage('xxxxx.jpg');
  $img->setImageFormat('png'); 
  $fuzz = Imagick::getQuantum() * 0.1; // 10%
  $img->transparentPaintImage($BackgroundColor,0,$fuzz,false);
  $img->writeImage('xxxx.png');

Any idea ?

Problems with the site

Hello. I wanted to see some examples of working with Imagick on your site, but I could not because of the error. Do something, please, so that we can continue to look at the examples)

Imagick hang APache server in XAMPP when converting PDF to PNG

I can´t solve after round it for all thre side: Imagick hang Apache server in XAMPP when converting PDF to PNG.
In the attached zip, a video about the code that convert and the result in localhost, when I set a mistaken folder, there is an error message in the browser, when there´s no mistaken fodler, hang the server.

I will thnak you very much your help.

ScreenHunter 535.zip

Problems with FastCgi in PHP v.7.1.7 when Imagick is active

Hello expert,
Recently, my websites running (on the same 32-bit webserver) under PHP version 7.1.7 crash many times (Internal Server Error 500) or are 'frozen' in a process (Loading data...) which does not end.
The Internal Server Error is traced back to a FastCGI problems/failures.
Sometimes, refreshing the browser-window (F5 or ctrl-R) helps, but often I have to restart my webserver entirely (hard-reboot).

Error message:
"HTTP Error 500.0 - Internal Server Error. The FastCGI process has failed frequently recently. Try the request again in a while."

A. Example Piwigo (online photo album showcase):
Clicking in album categories of Piwigo and on individual photo's for detail-page cause the same FastCGI error message.
This happens especially when handling GIF-animations, which are resized on the fly by the Imagick-plugin.
(The website also contains the PicLens 3D Wall plugin [Adobe Flash]).

The Imagick-plugin in Piwigo needs C++ runtime:
This will not work in combination with the latest version: Microsoft Visual Studio C++ 2017 Redistributable (x86) 14.10.25017 .
This may work with: Microsoft Visual C++ 2015 Redistributable (x86) - 14.0.23026 , but often results in 'frozen' webserver.

B. Example Piwik (web-statistics analysis):
Clicking on the webpages of Piwik, navigation towards a monitored website:
Piwik: Settings | Websites | Manage -->
Piwik-site page gets stuck in 'Loading data...' or displays error message:
"HTTP Error 500.0 - Internal Server Error. The FastCGI process has failed frequently recently. Try the request again in a while."
The statistically calculated content of the Piwigo-site (visitor activities) is often blanc in Piwik detail-pages, and sometimes filled with appropriate data.


Overal performance: these PHP-sites have become slow and unpredictable.
(As webbrowser, I used the updated versions of: Edge, Firefox and Opera.)

Do you know what the correct combination/implementation/settings should be, to get these websites working properly, regarding versions of: Piwik, Piwigo, Imagick, Visual C++ Redistributable, PHP - FastCgi ?

Environment:
Piwigo 2.9.2 (www.rolfsnijders.net)
Piwik 3.2.0

Operating system: WINNT: Windows 10 prof 32bit, webserver: IIS 10
PHP: 7.1.7 [2017-11-21]
MySQL: 5.5.54

Imagick Graphics Library: External ImageMagick 7.0.5-1
Installed on webserver:
a) ImageMagick-7.0.5-1-Q16-x86-dll.exe (desktop software).
b) Relevant content of: php_imagick-3.4.3rc4-7.1-nts-vc14-x86.zip (PHP-extension).

Friendly regards,
Rolf

Convert jpg image to transparent png image using Imagick

Hello,
I want to convert a jpg image file to transparent png image file for this I am using ImageMagick commands as follows

  1. convert original.jpg -fuzz 2% -transparent white fuz.png
  2. convert fuz.png -fx 'a==0 ? HotPink : u' tmp.png
  3. convert tmp.png ( +clone -fx 'p{0,0}' ) -compose Difference -composite -modulate 100,0 -alpha off dif.png
  4. convert dif.png -bordercolor black -border 2 -threshold 2% -blur 0x3 msk.png
  5. convert original.jpg -bordercolor white -border 2 msk.png -alpha Off -compose CopyOpacity -composite target.png

In these commands "original.jpg" is the original image and "target.png" is the required png image. By using these commands I am able to do what I required but I want to do the same in PHP using Imagick.

So, please anybody provide the Imagick php code for the same.

Thank

Effect Preview error.

Reported from Imagick::selectiveBlurImage

original and modified images doesn't has any difference whatever parameters given.

Method filter from Imagick

Reported from Imagick::filter

I have a problem with method filter from the class Imagick.

I expect to have an answer for it's used or solve it.

Thank you, i will be waiting your answer.

Unable to set image alpha channel with setImageAlphaChannel method

I'm trying to create transparent image with ImageMagick with the backgroundMasking method which I found on http://phpimagick.com/Tutorial/backgroundMasking but I got errors as below messages.

This is my ImageMagick invironment

Version: ImageMagick 7.0.5-4 Q16 x86_64 2017-04-03 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP
Delegates (built-in): bzlib djvu fontconfig freetype gvc jbig jng jpeg lcms lqr lzma openexr png tiff wmf x xml zlib

However I've run ./configure --enable-hdri --with-quantum-depth=32 and make install commend but I'm still facing this problem.

Problem

Unable to set image alpha channel

function backgroundMasking()
{
   //Load the image
   $imagick = new \Imagick(realpath('images/chair.jpeg'));

   $backgroundColor = "rgb(255, 255, 255)";
   $fuzzFactor = 0.1;

   // Create a copy of the image, and paint all the pixels that
   // are the background color to be transparent
   $outlineImagick = clone $imagick;
   $outlineImagick->transparentPaintImage(
       $backgroundColor, 0, $fuzzFactor * \Imagick::getQuantum(), false
   );
    
   // Copy the input image
   $mask = clone $imagick;
   // Deactivate the alpha channel if the image has one, as later in the process
   // we want the mask alpha to be copied from the colour channel to the src
   // alpha channel. If the mask image has an alpha channel, it would be copied
   // from that instead of from the colour channel.
   $mask->setImageAlphaChannel(\Imagick::ALPHACHANNEL_DEACTIVATE);
   //Convert to gray scale to make life simpler
   $mask->transformImageColorSpace(\Imagick::COLORSPACE_GRAY);

   // DstOut does a "cookie-cutter" it leaves the shape remaining after the
   // outlineImagick image, is cut out of the mask.
   $mask->compositeImage(
       $outlineImagick,
       \Imagick::COMPOSITE_DSTOUT,
       0, 0
   );
    
   // The mask is now black where the objects are in the image and white
   // where the background is.
   // Negate the image, to have white where the objects are and black for
   // the background
   $mask->negateImage(false);

   $fillPixelHoles = false;
    
   if ($fillPixelHoles == true) {
       // If your image has pixel sized holes in it, you will want to fill them
       // in. This will however also make any acute corners in the image not be
       // transparent.
        
       // Fill holes - any black pixel that is surrounded by white will become
       // white
       $mask->blurimage(2, 1);
       $mask->whiteThresholdImage("rgb(10, 10, 10)");

       // Thinning - because the previous step made the outline thicker, we
       // attempt to make it thinner by an equivalent amount.
       $mask->blurimage(2, 1);
       $mask->blackThresholdImage("rgb(255, 255, 255)");
   }

   //Soften the edge of the mask to prevent jaggies on the outline.
   $mask->blurimage(2, 2);

   // We want the mask to go from full opaque to fully transparent quite quickly to
   // avoid having too many semi-transparent pixels. sigmoidalContrastImage does this
   // for us. Values to use were determined empirically.
   $contrast = 15;
   $midpoint = 0.7 * \Imagick::getQuantum();
   $mask->sigmoidalContrastImage(true, $contrast, $midpoint);

   // Copy the mask into the opacity channel of the original image.
   // You are probably done here if you just want the background removed.
   $imagick->compositeimage(
       $mask,
       \Imagick::COMPOSITE_COPYOPACITY,
       0, 0
   );

   // To show that the background has been removed (which is difficult to see
   // against a plain white webpage) we paste the image over a checkboard
   // so that the edges can be seen.
    
   // Create the check canvas
   $canvas = new \Imagick();
   $canvas->newPseudoImage(
       $imagick->getImageWidth(),
       $imagick->getImageHeight(),
       "pattern:checkerboard"
   );

   // Copy the image with the background removed over it.
   $canvas->compositeimage($imagick, \Imagick::COMPOSITE_OVER, 0, 0);
    
   //Output the final image
   $canvas->setImageFormat('png');
   header("Content-Type: image/png");
   echo $canvas->getImageBlob();
}

Facing below error

Reported from Tutorial::backgroundMasking

PHP Fatal error: ImagickDemo\Config::__construct(): Failed opening required '/var/app/src/ImagickDemo/../../config.php' (include_path='.:/usr/share/php') in /var/app/src/ImagickDemo/Config.php on line 50

PHP Warning: Version warning: Imagick was compiled against Image Magick version 1654 but version 1650 is loaded

Hello everyone.

In my hosting at Hostgator I am receiving this error without stopping in the "error_log" file.

The file "error_log" containing this message appears on several random pages.

In addition, I receive the following message every hour, in the standard cpanel email:
Title:
Cron <delaio86 @ srv100> / usr / bin / php -f /home2/delaio86/public_html/utilidadeninja.com/site/wp-cron.php> / dev / null
Content:

PHP Warning: Module 'imagick' already loaded in Unknown on line 0
PHP Warning: Version warning: Imagick was compiled against Image Magick version 1654 but version 1650 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0

In contact with the Hosting, I was informed that this is an incompatibility of Imagick with versions 73 and 74 of PHP.

The attendant then said that he could not do anything because it is a shared hosting and suggested that I use an outdated version "72" of php.

I said that I would not use an outdated version, for obvious reasons.

I would like your help to try to stop generating these messages in the log for all my folders without having to outdate my PHP.

I often have to look for the files and delete them one by one, as they never stop growing.

I already tried to insert a .user.ini file containing the line:
imagick.skip_version_check = true
And a php.ini file with the line:
extension = imagick.so

Both, in the root folder of the hosting, the errors continue to appear randomly.

Thanks in advance to anyone who can help.

Redundant code in example.

Reported from Imagick::remapImage

On the web page for remapImage, the following line is redundant.

$imagick2 = new \Imagick(realpath("images/VGA_palette_with_black_borders.png"));

sketchImage

Reported from Imagick::sketchImage

Trying to use sketchImage for sketching the user's image by using $im1->sketchimage(5, 1, 45);
but, getting blur sort of output only.
Can you please help out in this?

mod_mpm_worker and mod_mpm_event

In Apache the ImageMagick PECL module only works with mod_mpm_prefork.so - it will not load if either mod_mpm_worker.so or mod_mpm_event.so are used instead.

The problem with using mod_mpm_prefork.so in Apache is it prevents things like the PHP session based upload progress from working, because additional requests from the client to get the status of the upload are not answered by the server until the upload is finished.

But using using the alternative mpm modules literally breaks ImageMagick processing in PHP.

Need code to extend the image vertically

Reported from Tutorial::edgeExtend

This page: http://phpimagick.com/Tutorial/edgeExtend provides an example for extending an image horizontally. Would appreciate an example to extend an image vertically.

Also, the example is difficult to follow, with comments poorly placed.
Better would be the following code:

$originalWidth = $img->getImageWidth();
$desiredWidth = $originalWidth+120;
$XFactor=$originalWidth / $desiredWidth;
$XOffset=($desiredWidth - $originalWidth) / 2;
$img->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_MIRROR);
$img->sampleimage($desiredWidth, $img->getImageHeight()); //Make the image be the desired width.
$points=array($XFactor,0,0,1,$XOffset,0);
$img->distortImage(Imagick::DISTORTION_AFFINEPROJECTION,$points,false);

[In the $points array.... what do the arguments actually do?]

Example->compositeImage($file, COMPOSITE_ATOP) WITH Outside-Overlay = false

THANK YOU for your work and this content!

When looping through gif animations and overlaying a png image that has some opacity I get the best results using the COMPOSITE_ATOP filter - much better than COMPOSITE_OVER.

The manual and this tutorial (https://legacy.imagemagick.org/Usage/compose/#outside-overlay) says I can override the default behavior of ATOP (Duff-Porter methods) which clears the destination image that is outside of the source image. I am using the php-fpm function calls and not the command line. I cannot find a good/working example on how to issue the "-define outside-overlay=false" argument. Taken from the manual:

PHP Manual (https://www.php.net/manual/en/imagick.compositeimage.php) states:
"Any extra arguments needed for the compose algorithm should passed to setImageArtifact with 'compose:args' as the first parameter and the data as the second parameter."

I would've thought line 1 would have worked, but 3 onward is just flailing for a solution.

  1. $overlayImg->setImageArtifact("compose:args", "outside-overlay=false");
  2. $overlayImg->setImageArtifact("compose:outside-overlay",false);
  3. $overlayImg->setImageArtifact("compose:outside-overlay",0);
  4. $overlayImg->setImageArtifact("compose:args", "-define outside-overlay=false");
  5. $overlayImg->setImageArtifact("compose:args","outside-overlay=false");
    ... and then ...
    $frame->compositeImage($overlayImg, \Imagick::COMPOSITE_ATOP,0,0);

The setImageArtifact signature is:
public Imagick::setImageArtifact ( string $artifact , string $value ) : bool

That got me even passing 'false' as a string and not a boolean. Nothing's working for me. Apparently I'm wrapped around the axle.

Thanks for any help.
PS. Previously, I had tried with some exec and shell_exec commands but failed with those too.

i may have broken http://phpimagick.com/

was playing around with the whirlygif demo and now every page at phpimagick.com has an error message on it !

( 4 me at least ! )

Exception Predis\Connection\ConnectionException: 'Connection refused [tcp://127.0.0.1:6379]'

etc.

System tmp dir gets full

Because the file filters write to /tmp this can fill up and get slow.

We should either/both:

i) Clean up the old files

ii) use Tier\Path\TempPath

How to compress PNG format image by using Imagick

Hi

I was trying to compress PNG format image but its not working properly below is the code i was using

$i->setImageFormat("png");
$i->setImageCompression(Imagick::COMPRESSION_ZIP);
$i->setOption('png:compression-level',7);
$i->setOption('png:compression-strategy',4);
$i->setOption('png:compression-filter',4);
$i->setOption('png:format','png8');
$i->setOption('png:bit-depth',8);
$i->stripImage();

Imagemagick vs. Imagick

Can you tell where the difference between IM and Imagick is?
I'd like to develop a small script on Imagick. But I'm not sure if it supports all the features of ImageMagick (16 bit for example).

Further it does not support plugins; is there any way around this limitation?
Many Thanks

Imagick for PHP 8 on cPanel

Hello,

I use cPanel and would like to start using PHP 8. Imagick is wonderful and produces higher resolution images than GD, so plan on waiting to Imagick to be compatible with PHP 8 and cPanel.

Thank you.

Andy Bajka

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.