Recherche avancée

Médias (91)

Autres articles (64)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à 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) (...)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La 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 (5425)

  • Padding thumbnail with color

    9 juin 2010, par Mikko Koppanen — Imagick, PHP stuff

    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.

    1. < ?php
    2. /* Define width and height of the thumbnail */
    3. $width = 100 ;
    4. $height = 100 ;
    5.  
    6. /* Instanciate and read the image in */
    7. $im = new Imagick( "test.png" ) ;
    8.  
    9. /* Fit the image into $width x $height box
    10.  The third parameter fits the image into a "bounding box" */
    11. $im->thumbnailImage( $width, $height, true ) ;
    12.  
    13. /* Create a canvas with the desired color */
    14. $canvas = new Imagick() ;
    15. $canvas->newImage( $width, $height, ’pink’, ’png’ ) ;
    16.  
    17. /* Get the image geometry */
    18. $geometry = $im->getImageGeometry() ;
    19.  
    20. /* The overlay x and y coordinates */
    21. $x = ( $width - $geometry[’width’] ) / 2 ;
    22. $y = ( $height - $geometry[’height’] ) / 2 ;
    23.  
    24. /* Composite on the canvas */
    25. $canvas->compositeImage( $im, imagick: :COMPOSITE_OVER, $x, $y ) ;
    26.  
    27. /* Output the image*/
    28. header( "Content-Type : image/png" ) ;
    29. echo $canvas ;
    30.  
    31.  ?>

    The source image :
    test.png

    The resulting image :
    testphp.png

  • Typesetting

    9 juin 2010, par Mikko Koppanen — Imagick, PHP stuff

    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.

    1. < ?php
    2.  
    3. /* How wide is our image */
    4. $image_width = 200 ;
    5.  
    6. /* Give zero for autocalculating the height */
    7. $image_height = 200 ;
    8.  
    9. /* Specify the text */
    10. $text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
    11.     Mauris lectus mi, mattis non, euismod vel, sagittis nec, ipsum." ;
    12.  
    13. /* Instanciate imagick */
    14. $im = new Imagick() ;
    15.  
    16. /* Create new image using caption : pseudo format */
    17. $im->newPseudoImage( $image_width, $image_height, "caption :" . $text ) ;
    18.  
    19. /* Put 1px border around the image */
    20. $im->borderImage( ’black’, 1, 1 ) ;
    21.  
    22. /* PNG format */
    23. $im->setImageFormat( "png")  ;
    24.  
    25. /* Output */
    26. header( "Content-Type : image/png" ) ;
    27. echo $im ;
    28.  
    29.  ?>

    Here is image with width 100 and height 0 :

    width_100_height_0.png

    Width 100 Height 50 :

    width_100_height_50.png

    Width 200 Height 200 (as you can see the font size is now larger) :

    width_200_height_200.png

  • Fill patterns

    9 juin 2010, par Mikko Koppanen — Imagick, PHP stuff

    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.

    1. < ?php
    2.  
    3. /* Create a new imagick object */
    4. $im = new Imagick( ’iceformations5679.JPG’ ) ;
    5.  
    6. /* Create imagickdraw object */
    7. $draw = new ImagickDraw() ;
    8.  
    9. /* Start a new pattern called "ice" */
    10. $draw->pushPattern( ’ice’ , 0 , 0 , 50 , 50 ) ;
    11.  
    12. /* Composite the image on the pattern */
    13. $draw->composite( Imagick: :COMPOSITE_OVER, 0, 0, 50, 50, $im ) ;
    14.  
    15. /* Close the pattern */
    16. $draw->popPattern() ;
    17.  
    18. /* Use the pattern called "ice" as the fill */
    19. $draw->setFillPatternURL( ’#ice’ ) ;
    20.  
    21. /* Set font size to 52 */
    22. $draw->setFontSize( 52 ) ;
    23.  
    24. /* Annotate some text */
    25. $draw->annotation( 5, 50, "Hello World !" ) ;
    26.  
    27. /* Create a new canvas and white image */
    28. $canvas = new Imagick() ;
    29. $canvas->newImage( 310, 70, "white" ) ;
    30.  
    31. /* Add black border around the resulting image */
    32. $canvas->borderImage( ’black’, 1, 1 ) ;
    33.  
    34. /* Draw the ImagickDraw on to the canvas */
    35. $canvas->drawImage( $draw ) ;
    36.  
    37. /* Set the format to PNG */
    38. $canvas->setImageFormat( ’png’ ) ;
    39.  
    40. /* Output the image */
    41. header( "Content-Type : image/png" ) ;
    42. echo $canvas ;
    43.  ?>

    And the result is here :