
Recherche avancée
Médias (91)
-
Collections - Formulaire de création rapide
19 février 2013, par
Mis à jour : Février 2013
Langue : français
Type : Image
-
Les Miserables
4 juin 2012, par
Mis à jour : Février 2013
Langue : English
Type : Texte
-
Ne pas afficher certaines informations : page d’accueil
23 novembre 2011, par
Mis à jour : Novembre 2011
Langue : français
Type : Image
-
The Great Big Beautiful Tomorrow
28 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Texte
-
Richard Stallman et la révolution du logiciel libre - Une biographie autorisée (version epub)
28 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Texte
-
Rennes Emotion Map 2010-11
19 octobre 2011, par
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (78)
-
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...) -
Emballe médias : à quoi cela sert ?
4 février 2011, parCe plugin vise à gérer des sites de mise en ligne de documents de tous types.
Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ; -
Le plugin : Gestion de la mutualisation
2 mars 2010, parLe plugin de Gestion de mutualisation permet de gérer les différents canaux de mediaspip depuis un site maître. Il a pour but de fournir une solution pure SPIP afin de remplacer cette ancienne solution.
Installation basique
On installe les fichiers de SPIP sur le serveur.
On ajoute ensuite le plugin "mutualisation" à la racine du site comme décrit ici.
On customise le fichier mes_options.php central comme on le souhaite. Voilà pour l’exemple celui de la plateforme mediaspip.net :
< ?php (...)
Sur d’autres sites (4409)
-
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 ;
-
-
?>
-
-
Typesetting
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 !
Here is a small example of how to fit a certain piece of a string on to an area of which you know the width and the height or only the width. The magic happens through the ImageMagick CAPTION : format. You can see from the example images how the parameters actually affect the image.
-
< ?php
-
-
/* How wide is our image */
-
$image_width = 200 ;
-
-
/* Give zero for autocalculating the height */
-
$image_height = 200 ;
-
-
/* Specify the text */
-
$text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
-
Mauris lectus mi, mattis non, euismod vel, sagittis nec, ipsum." ;
-
-
/* Instanciate imagick */
-
$im = new Imagick() ;
-
-
/* Create new image using caption : pseudo format */
-
$im->newPseudoImage( $image_width, $image_height, "caption :" . $text ) ;
-
-
/* Put 1px border around the image */
-
$im->borderImage( ’black’, 1, 1 ) ;
-
-
/* PNG format */
-
$im->setImageFormat( "png") ;
-
-
/* Output */
-
header( "Content-Type : image/png" ) ;
-
echo $im ;
-
-
?>
Here is image with width 100 and height 0 :
Width 100 Height 50 :
Width 200 Height 200 (as you can see the font size is now larger) :
-
-
Fill patterns
My work life has been quite busy lately and I haven’t had a chance to sit down and blog. I have been touring around London and some parts of the northern England consulting and organizing some training here and there. Luckily I have had the chance to do some work on Imagick and the 2.2.0 beta release is getting closer. The internal structure was completely restructured and broken down into several smaller files. During this time Imagick was adapted to follow the PHP Coding Standards more closely. Still a work in progress
I committed slightly modified version of this example to PHP Manual http://uk.php.net/manual/en/imagick.examples.php page a few days ago. The example illustrates using an image as a part of a named fill pattern. The fill pattern is used to annotate text but the named pattern could also be used to fill any shapes that allow fill to be specified (include circles, ellipses, rectangles, polygons etc etc). The code itself is pretty straight forward : Read the image, create the pattern and use the pattern as a fill.
The ice formations image is from http://www.photoeverywhere.co.uk/west/winterholiday/slides/iceformations5679.htm.
-
< ?php
-
-
/* Create a new imagick object */
-
$im = new Imagick( ’iceformations5679.JPG’ ) ;
-
-
/* Create imagickdraw object */
-
$draw = new ImagickDraw() ;
-
-
/* Start a new pattern called "ice" */
-
$draw->pushPattern( ’ice’ , 0 , 0 , 50 , 50 ) ;
-
-
/* Composite the image on the pattern */
-
$draw->composite( Imagick: :COMPOSITE_OVER, 0, 0, 50, 50, $im ) ;
-
-
/* Close the pattern */
-
$draw->popPattern() ;
-
-
/* Use the pattern called "ice" as the fill */
-
$draw->setFillPatternURL( ’#ice’ ) ;
-
-
/* Set font size to 52 */
-
$draw->setFontSize( 52 ) ;
-
-
/* Annotate some text */
-
$draw->annotation( 5, 50, "Hello World !" ) ;
-
-
/* Create a new canvas and white image */
-
$canvas = new Imagick() ;
-
$canvas->newImage( 310, 70, "white" ) ;
-
-
/* Add black border around the resulting image */
-
$canvas->borderImage( ’black’, 1, 1 ) ;
-
-
/* Draw the ImagickDraw on to the canvas */
-
$canvas->drawImage( $draw ) ;
-
-
/* Set the format to PNG */
-
$canvas->setImageFormat( ’png’ ) ;
-
-
/* Output the image */
-
header( "Content-Type : image/png" ) ;
-
echo $canvas ;
-
?>
And the result is here :
-