Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Security Update:
Imagemagick - Multiple Vulnerabilities
May 05, 2016 @ 16:07:35

Imagemagick, a well-used alternative by PHP developers for graphics manipulation (an alternative to GD) has had several new vulnerabilities announced. These vulnerabilities allow for everything from remote code execution to initiating network requests. The Imagetragick site has more information:

There are multiple vulnerabilities in ImageMagick, a package commonly used by web services to process images. One of the vulnerabilities can lead to remote code execution (RCE) if you process user submitted images. The exploit for this vulnerability is being used in the wild.

A number of image processing plugins depend on the ImageMagick library, including, but not limited to, PHP’s imagick, Ruby’s rmagick and paperclip, and nodejs’s imagemagick. If you use ImageMagick or an affected library, we recommend you mitigate the known vulnerabilities.

There's two mitigations listed to help with a more immediate fix: using a policy.xml file and verifying that image data starts with the right "magic bytes". The site also shares more information about the different vulnerabilities and what kind of attacks they could allow. It is highly recommended that you add the mitigations they show and update your installation to use the latest release (7.0.1-1) with fixes for these issues.

tagged: imagemagick vulnerabilities multiple upgrade mitigation

Link: https://imagetragick.com

PHPMaster.com:
Crop and Resize Images with ImageMagick
May 02, 2013 @ 17:14:51

PHPMaster.com has a new tutorial posted showing you how to crop and resize images with the help of the ImageMagick functionality that can be added to PHP (via this extension).

If your website allows users to upload photos, image cropping/resizing functionality certainly comes in handy. But users might not have access to image manipulation tools like Photoshop, so by providing a cropping/resizing feature you can allow users to upload photos from any device (e.g. tablets or phones) without them having to worry about the the final size. Furthermore, you can create different versions of the same image and also allow users to crop specific portions of uploaded picture. In this article I’ll show you how to create an image cropping tool with the help of the ImageMagick PHP extension.

The post shows the use of the "cropimage" function to trim down an image from its original size and "thumbnailImage" to shrink down the image to make a thumbnail. Also included is the code (both the PHP and the HTML form) to handle file uploads and automatically create a thumbnail image. It outputs the image to the browser and asks the user to select the portion they want thumbnailed (with this jQuery plugin helping).

tagged: crop image imagemagick tutorial resize extension

Link: http://phpmaster.com/crop-and-resize-images-with-imagemagick

NetTuts.com:
Create Instagram Filters With PHP
Mar 26, 2012 @ 15:07:37

On NetTuts.com there's a new tutorial showing how you can create Instagram-like filters in PHP using the ImageMagick library/extension.

PHP comes bundled with GD (GIF Draw/Graphics Draw), which is a library for the dynamic creation of images. It can be used for simpler image operation, such as resizing, cropping, adding watermarks, creating thumbnails (Jeffrey wrote about it), applying basic photo filters – you’ve probably used it before. Unfortunately, if you want to create something more complex with GD, like Instagram effects, you can’t. Luckily, though, we have ImageMagick!

He starts off by comparing the two graphics libraries and talks briefly about how to downliad and install Imagemagick on your development platform. Included is a PHP class to help you use it, coming complete with functions for changing the color tone of the image, adding a border and adding a vignette to the image. Also included are some "presets" represented in a few simple functions:

  • Gotham
  • Toaster
  • Nashville
  • Lomo
  • Kelvin

There's also a few links to other resources you can use to find out more details on what Imagemagick has to offer.

tagged: instagraph photo imagemagick filter tutorial image

Link:

Martin Psinas' Blog:
Watermarking with text and ImageMagick
Oct 04, 2011 @ 16:44:35

Martin Psinas has submitted a new tutorial he's written up (complete with sample code) showing how to watermark an image with ImageMagick.

In my most recent venture with PHPMaster I was asked to write an article about watermarking images with PHP using ImageMagick. Virtually no documentation exists on the PHP API, although there are plenty of command-line examples from the official ImageMagick website. I spent a solid day and a half attempting to convert command-line code into PHP before (due to miscommunication) the topic was covered by someone else and my work was no longer needed. Although disappointed, it gave me something to blog about! Yay.

His script is pretty straight forward - it loads a sample image, sets up some watermark text and applies it with a "gravity" setting of "southwest" and adds it to the image (annotateImage). The output is pushed back out as a JPEG image. Also included is a slightly more complex example showing how to give the watermark an embossed look and a "text all over the image" look to prevent use of any part of the image, not just one section.

tagged: watermark text image tutorial imagemagick emboss

Link:

Mikko Koppanen's Blog:
Perspective transformations
Feb 05, 2009 @ 15:36:02

Mikko Koppanen is back to blogging with this new post today - it's a look at another example with ImageMagick. It shows how to distort an image but keep its perspective.

I took some time to actually understand the perspective transformations properly using the excellent ImageMagick examples (mainly created by Anthony Thyssen) as a reference. The basic idea of perspective distortion seems simple: to distort the control points to new locations.

His example uses a checkerboard as the image to manipulate and, based on an array of settings (source, destination) sets control points for the image to twist and turn from. The final output is echoed from a call to distortImage.

tagged: perspective transformation imagemagick twist bendexample

Link:

The Bakery:
Five New Articles/Tutorials/Components Posted
Jun 06, 2008 @ 17:07:47

The Bakery, the CakePHP repository, has had several new components, articles and tutorials posted lately. Here's a list of a few:

Be sure to check out The Bakery for more great articles, tutorial, components and helpers for this flexible framework.

tagged: article post thebakery svn tidy imagemagick mysql

Link:

Mikko Koppanen's Blog:
Seam carving
Feb 13, 2008 @ 23:10:00

Mikko Koppanen has posted another quick hit ImageMagick hint to his blog - this time it deal with "seam carving", a process for cropping and resampling of an image to make a different composite picture.

Today I was reading trough the ImageMagick ChangeLog and noticed an interesting entry. "Add support for liquid rescaling". I rushed to check the MagickWand API docs and there it was: MagickLiquidRescaleImage! After about ten minutes of hacking the Imagick support was done. Needless to say; I was excited

You'll need to have the libqr library compiled into the ImageMagick installation, but the actual use of the functionality is simple - about three or four lines do the work for you. He includes the original image and the result from his test (as well as another example of the same result image scaled down automatically.

tagged: imagemagick seam carving image resize libqr

Link:

Mikko Koppanen's Blog:
Typesetting
Jan 17, 2008 @ 13:58:00

Mikko Koppanen has posted another quick example of using the ImageMagick functionality in PHP - overlaying a string of text over a currently existing image.

Ever had the situation where you have a piece of string which you need to overlay on an image? Maybe a situation where the area reserved for the string is known in pixels but you need to know the font size to fill most of the area? Think no more!

In his example (ready to cut and paste), he defines the text in a variable and, with the help of the newPseudoImage method, adds the text over the top of his sample image. Example input and output is provided.

tagged: imagemagick image graphic typesetting string overlay imagemagick image graphic typesetting string overlay

Link:

Mikko Koppanen's Blog:
Typesetting
Jan 17, 2008 @ 13:58:00

Mikko Koppanen has posted another quick example of using the ImageMagick functionality in PHP - overlaying a string of text over a currently existing image.

Ever had the situation where you have a piece of string which you need to overlay on an image? Maybe a situation where the area reserved for the string is known in pixels but you need to know the font size to fill most of the area? Think no more!

In his example (ready to cut and paste), he defines the text in a variable and, with the help of the newPseudoImage method, adds the text over the top of his sample image. Example input and output is provided.

tagged: imagemagick image graphic typesetting string overlay imagemagick image graphic typesetting string overlay

Link:

SitePoint.com:
Create Dynamic Images with ImageMagick
Jun 26, 2006 @ 11:48:53

Over on SitePoint.com today, there's a new tutorial demonstrating an alternative to the usual GD library examples of working with images, opting instead for ImageMagick.

The key component for making dynamic images a reality on your site is an image manipulation program that's controlled by the code that generates your web pages. Even though this article uses PHP as the scripting language, other languages -- such as Perl and Ruby -- can be used just as easily, provided that the image manipulation program that you're considering has an application programming interface (API) for the chosen language.

He decided on ImageMagick for a few reasons, including that it's more supported by web hosts, it runs on Windows and Linux, and it's robust and powerful enough to handle everything from small to large tasks without missing a beat.

That said, he gets into the code, showing how a bit of PHP code can read in an image and spit back out information about it (height, width, etc), force a reduction of an uploaded image, scale down an image to fit a certian size, change it to a different type of image, and image rotation.

tagged: imagemagick dynamic image manipulation extension tutorial imagemagick dynamic image manipulation extension tutorial

Link:


Trending Topics: