
Recherche avancée
Autres articles (11)
-
Installation en mode ferme
4 février 2011, parLe mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
C’est la méthode que nous utilisons sur cette même plateforme.
L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...) -
Support de tous types de médias
10 avril 2011Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)
-
Supporting all media types
13 avril 2011, parUnlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)
Sur d’autres sites (5788)
-
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) :
-
-
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 ;
-
-
?>
-
-
Creating buttons with Imagick
A fellow called kakapo asked me to create a button with Imagick. He had an image of the button and a Photoshop tutorial but unfortunately the tutorial was in Chinese. My Chinese is a bit rusty so it will take a little longer to create that specific button
The button in this example is created after this tutorial http://xeonfx.com/tutorials/easy-button-tutorial/ (yes, I googled “easy button tutorial”). The code and the button it creates are both very simple but the effect looks really nice.
Here we go with the code :
-
< ?php
-
-
/* Create a new Imagick object */
-
$im = new Imagick() ;
-
-
/* Create empty canvas */
-
$im->newImage( 200, 200, "white", "png" ) ;
-
-
/* Create the object used to draw */
-
$draw = new ImagickDraw() ;
-
-
/* Set the button color.
-
Changing this value changes the color of the button */
-
$draw->setFillColor( "#4096EE" ) ;
-
-
/* Create the outer circle */
-
$draw->circle( 50, 50, 70, 70 ) ;
-
-
/* Create the smaller circle on the button */
-
$draw->setFillColor( "white" ) ;
-
-
/* Semi-opaque fill */
-
$draw->setFillAlpha( 0.2 ) ;
-
-
/* Draw the circle */
-
$draw->circle( 50, 50, 68, 68 ) ;
-
-
/* Set the font */
-
$draw->setFont( "./test1.ttf" ) ;
-
-
/* This is the alpha value used to annotate */
-
$draw->setFillAlpha( 0.17 ) ;
-
-
/* Draw a curve on the button with 17% opaque fill */
-
$draw->bezier( array(
-
array( "x" => 10 , "y" => 25 ),
-
array( "x" => 39, "y" => 49 ),
-
array( "x" => 60, "y" => 55 ),
-
array( "x" => 75, "y" => 70 ),
-
array( "x" => 100, "y" => 70 ),
-
array( "x" => 100, "y" => 10 ),
-
) ) ;
-
-
/* Render all pending operations on the image */
-
$im->drawImage( $draw ) ;
-
-
/* Set fill to fully opaque */
-
$draw->setFillAlpha( 1 ) ;
-
-
/* Set the font size to 30 */
-
$draw->setFontSize( 30 ) ;
-
-
/* The text on the */
-
$draw->setFillColor( "white" ) ;
-
-
/* Annotate the text */
-
$im->annotateImage( $draw, 38, 55, 0, "go" ) ;
-
-
/* Trim extra area out of the image */
-
$im->trimImage( 0 ) ;
-
-
/* Output the image */
-
header( "Content-Type : image/png" ) ;
-
echo $im ;
-
-
?>
And here is a few buttons I created by changing the fill color value :
-