
Recherche avancée
Médias (1)
-
Revolution of Open-source and film making towards open film making
6 octobre 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (55)
-
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
Des sites réalisés avec MediaSPIP
2 mai 2011, parCette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page. -
Les tâches Cron régulières de la ferme
1er décembre 2010, parLa gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
Le super Cron (gestion_mutu_super_cron)
Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)
Sur d’autres sites (7132)
-
Padding thumbnail with color
I know, it’s been a while since I last blogged. This is because a lot of things are happening in my personal life. I recently relocated to London from Finland and started a new job. Things are quite busy but I will try to post an example now and then. In the meanwhile I would like to hear about sites using Imagick, so if your project is not super secret please post an url and maybe a small explanation what you’re doing with Imagick on the site. This is purely for my personal interest.
Anyway, to the point. Today’s example originates from a question asked by a user. How do I thumbnail the image inside given dimensions proportionally and fill the “blank” areas with a color ? Well, the answer is here
The code is for Imagick 2.1.0 but adapting to older versions should not be hard.
-
< ?php
-
/* Define width and height of the thumbnail */
-
$width = 100 ;
-
$height = 100 ;
-
-
/* Instanciate and read the image in */
-
$im = new Imagick( "test.png" ) ;
-
-
/* Fit the image into $width x $height box
-
The third parameter fits the image into a "bounding box" */
-
$im->thumbnailImage( $width, $height, true ) ;
-
-
/* Create a canvas with the desired color */
-
$canvas = new Imagick() ;
-
$canvas->newImage( $width, $height, ’pink’, ’png’ ) ;
-
-
/* Get the image geometry */
-
$geometry = $im->getImageGeometry() ;
-
-
/* The overlay x and y coordinates */
-
$x = ( $width - $geometry[’width’] ) / 2 ;
-
$y = ( $height - $geometry[’height’] ) / 2 ;
-
-
/* Composite on the canvas */
-
$canvas->compositeImage( $im, imagick: :COMPOSITE_OVER, $x, $y ) ;
-
-
/* Output the image*/
-
header( "Content-Type : image/png" ) ;
-
echo $canvas ;
-
-
?>
-
-
Seam carving
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
For those who don’t know what seam carving is check the demo here. More detailed information about the algorithm can be found here : “Seam Carving for Content-Aware Image Resizing” by Shai Avidan and Ariel Shamir
To use this functionality you need to install at least ImageMagick 6.3.8-2 and liblqr. Remember to pass –with-lqr to ImageMagick configuration line. You can get liblqr here : http://liblqr.wikidot.com/. The Imagick side of the functionality should appear in the CVS today if everything goes as planned.
Here is a really simple example just to illustrate the results of the operation. The parameters might be far from optimal (didn’t do much testing yet). The original dimensions of image are 500×375 and the resulting size is 500×200.
Update : the functionality is pending until license issues are solved.
-
< ?php
-
-
/* Create new object */
-
$im = new Imagick( ’test.jpg’ ) ;
-
-
/* Scale down */
-
$im->liquidRescaleImage( 500, 200, 3, 25 ) ;
-
-
/* Display */
-
header( ’Content-Type : image/jpg’ ) ;
-
echo $im ;
-
-
?>
The original image by flickr/jennconspiracy
And the result :
Update. On kenrick’s request here is an image which is scaled down to 300×300
-
-
Revision 37293 : Retour en arrière (suppression de la noisette)
15 avril 2010, par joseph@… — LogRetour en arrière (suppression de la noisette)