Recherche avancée

Médias (0)

Mot : - Tags -/médias

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (48)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette 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.

  • Soumettre améliorations et plugins supplémentaires

    10 avril 2011

    Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
    Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

Sur d’autres sites (8984)

  • 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 :

  • Fill patterns

    26 avril 2008, 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 :

  • Python cv2 script that scans a giant image to a video. Raises error : Unknown C++ exception from OpenCV code

    26 avril 2022, par Mahrarena

    I wrote a script that scans a giant image to make a video. Normally I just post my scripts straight to my Code Review account, but this script is ugly, needs to be refactored, implements only horizontal scrolling and contains a bug that I can't get rid of.

    &#xA;

    It is working but not perfect, I can't get the last line at the bottom of the image, with height of image_height % 1080. If I ignore it, the code is working fine, if I try to fix it, it throws exceptions.

    &#xA;

    Example :

    &#xA;

    Original image (Google Drive)

    &#xA;

    Video Output (Google Drive)

    &#xA;

    As you can see from the video, everything is working properly except the fact that I can't get the bottom line.

    &#xA;

    Full working code

    &#xA;


    &#xA;
    import cv2&#xA;import numpy as np&#xA;import random&#xA;import rpack&#xA;from fractions import Fraction&#xA;from math import prod&#xA;&#xA;def resize_guide(image_size, target_area):&#xA;    aspect_ratio = Fraction(*image_size).limit_denominator()&#xA;    horizontal = aspect_ratio.numerator&#xA;    vertical = aspect_ratio.denominator&#xA;    unit_length = (target_area/(horizontal*vertical))**.5&#xA;    return (int(horizontal*unit_length), int(vertical*unit_length))&#xA;&#xA;fourcc = cv2.VideoWriter_fourcc(*&#x27;h264&#x27;)&#xA;FRAME = np.zeros((1080, 1920, 3), dtype=np.uint8)&#xA;&#xA;def new_frame():&#xA;    return np.ndarray.copy(FRAME)&#xA;&#xA;def center(image):&#xA;    frame = new_frame()&#xA;    h, w = image.shape[:2]&#xA;    yoff = round((1080-h)/2)&#xA;    xoff = round((1920-w)/2)&#xA;    frame[yoff:yoff&#x2B;h, xoff:xoff&#x2B;w] = image&#xA;    return frame&#xA;&#xA;def image_scanning(file, fps=60, pan_increment=64, horizontal_increment=8, fast_decrement=256):&#xA;    image = cv2.imread(file)&#xA;    height, width = image.shape[:2]&#xA;    assert width*height >= 1920*1080&#xA;    video_writer = cv2.VideoWriter(file&#x2B;&#x27;.mp4&#x27;, fourcc, fps, (1920, 1080))&#xA;    fit_height = True&#xA;    if height &lt; 1080:&#xA;        width = width*1080/height&#xA;        image = cv2.resize(image, (width, 1080), interpolation = cv2.INTER_AREA)&#xA;    aspect_ratio = width / height&#xA;    zooming_needed = False&#xA;    if 4/9 &lt;= aspect_ratio &lt;= 16/9:&#xA;        new_width = round(width*1080/height)&#xA;        fit = cv2.resize(image, (new_width, 1080), interpolation = cv2.INTER_AREA)&#xA;        zooming_needed = True&#xA;    &#xA;    elif 16/9 &lt; aspect_ratio &lt;= 32/9:&#xA;        new_height = round(height*1920/width)&#xA;        fit = cv2.resize(image, (1920, new_height), interpolation = cv2.INTER_AREA)&#xA;        fit_height = False&#xA;        zooming_needed = True&#xA;    &#xA;    centered = center(fit)&#xA;    for i in range(fps):&#xA;        video_writer.write(centered)&#xA;    if fit_height:&#xA;        xoff = round((1920 - new_width)/2)&#xA;        while xoff:&#xA;            if xoff - pan_increment >= 0:&#xA;                xoff -= pan_increment&#xA;            else:&#xA;                xoff = 0&#xA;            frame = new_frame()&#xA;            frame[0:1080, xoff:xoff&#x2B;new_width] = fit&#xA;            video_writer.write(frame)&#xA;    else:&#xA;        yoff = round((1080 - new_height)/2)&#xA;        while yoff:&#xA;            if yoff - pan_increment >= 0:&#xA;                yoff -= pan_increment&#xA;            else:&#xA;                yoff = 0&#xA;            frame = new_frame()&#xA;            frame[yoff:yoff&#x2B;new_height, 0:1920] = fit&#xA;            video_writer.write(frame)&#xA;    &#xA;    if zooming_needed:&#xA;        if fit_height:&#xA;            width_1, height_1 = new_width, 1080&#xA;        else:&#xA;            width_1, height_1 = 1920, new_height&#xA;        new_area = width_1 * height_1&#xA;        original_area = width * height&#xA;        area_diff = original_area - new_area&#xA;        unit_diff = area_diff / fps&#xA;        for i in range(1, fps&#x2B;1):&#xA;            zoomed = cv2.resize(image, resize_guide((width_1, height_1), new_area&#x2B;unit_diff*i), interpolation=cv2.INTER_AREA)&#xA;            zheight, zwidth = zoomed.shape[:2]&#xA;            zheight = min(zheight, 1080)&#xA;            zwidth = min(zwidth, 1920)&#xA;            frame = new_frame()&#xA;            frame[0:zheight, 0:zwidth] = zoomed[0:zheight, 0:zwidth]&#xA;            video_writer.write(frame)&#xA;    y, x = 0, 0&#xA;    completed = False&#xA;    while y != height - 1080:&#xA;        x = 0&#xA;        while x != width - 1920:&#xA;            if x &#x2B; horizontal_increment &#x2B; 1920 &lt;= width:&#xA;                x &#x2B;= horizontal_increment&#xA;                frame = image[y:y&#x2B;1080, x:x&#x2B;1920]&#xA;                video_writer.write(frame)&#xA;            else:&#xA;                x = width - 1920&#xA;                frame = image[y:y&#x2B;1080, x:x&#x2B;1920]&#xA;                for i in range(round(fps/3)):&#xA;                    video_writer.write(frame)&#xA;                if y == height - 1080:&#xA;                    completed = True&#xA;        while x != 0:&#xA;            if x - fast_decrement - 1920 >= 0:&#xA;                x -= fast_decrement&#xA;            else:&#xA;                x = 0&#xA;            frame = image[y:y&#x2B;1080, x:x&#x2B;1920]&#xA;            video_writer.write(frame)&#xA;        if y &#x2B; 2160 &lt;= height:&#xA;            y &#x2B;= 1080&#xA;        else:&#xA;            y = height - 1080&#xA;    cv2.destroyAllWindows()&#xA;    video_writer.release()&#xA;    del video_writer&#xA;

    &#xA;

    The above the the code needed to produce the example video. It is working but the bottom line is missing.

    &#xA;

    Now if I change the last few lines to this :

    &#xA;

            if y &#x2B; 2160 &lt;= height:&#xA;            y &#x2B;= 1080&#xA;        else:&#xA;            y = height - 1080&#xA;            x = 0&#xA;            while x != width - 1920:&#xA;                if x &#x2B; horizontal_increment &#x2B; 1920 &lt;= width:&#xA;                    x &#x2B;= horizontal_increment&#xA;                    frame = image[y:y&#x2B;1080, x:x&#x2B;1920]&#xA;                    video_writer.write(frame)&#xA;    cv2.destroyAllWindows()&#xA;    video_writer.release()&#xA;    del video_writer&#xA;

    &#xA;

    I expect it to include the bottom line, but it just throws exceptions instead :

    &#xA;

    OpenCV: FFMPEG: tag 0x34363268/&#x27;h264&#x27; is not supported with codec id 27 and format &#x27;mp4 / MP4 (MPEG-4 Part 14)&#x27;&#xA;OpenCV: FFMPEG: fallback to use tag 0x31637661/&#x27;avc1&#x27;&#xA;---------------------------------------------------------------------------&#xA;error                                     Traceback (most recent call last)&#xA; in <module>&#xA;----> 1 image_scanning("D:/collages/91f53ebcea2a.png")&#xA;&#xA; in image_scanning(file, fps, pan_increment, horizontal_increment, fast_decrement)&#xA;    122                     x &#x2B;= horizontal_increment&#xA;    123                     frame = image[y:y&#x2B;1080, x:x&#x2B;1920]&#xA;--> 124                     video_writer.write(frame)&#xA;    125     cv2.destroyAllWindows()&#xA;    126     video_writer.release()&#xA;&#xA;error: Unknown C&#x2B;&#x2B; exception from OpenCV code&#xA;</module>

    &#xA;

    (If you can't get the example code working I can't help you, but I am using Python 3.9.10 x64 on Windows 10, and I have this file : "C :\Windows\System32\openh264-1.8.0-win64.dll", the '.avi' format generates video files with Gibibytes (binary unit, not SI Gigabyte) of size)

    &#xA;

    How to get rid of the exception ?

    &#xA;


    &#xA;

    Okay I yield, I admit the tone of the original post was very aggressive and provoking, but I was very frustrated and I really don't know why my posts keep getting downvoted. Now I deleted all offending portions so will you people please really have a look at my code and tell me what I did wrong. I can solve it by myself, I always do, but I am so stupid I can spend hours missing the obvious. So please will you help me ?

    &#xA;