Converting images to another format with phMAgick

August 9, 2009 by nuno costa 15 comments

phMagick->convert()

Use this function to convert an image to another format

 

$p = new phmagick('source.jpg', 'destination.png');
$p->convert();

 

This example converts source.jpg to destination.png, optionaly setImageQuality() can be used to specify the quality of the new image

 

 

15 comments so far Add Your Comment

  1. by johny why on November 13 2009 at 12:10

    hi again
    can i convert pdf’s to gif’s?
    thanks!

  2. by nuno costa on November 16 2009 at 00:23

    @johny

    I’ve never tried converting pdf to gif’s, but there is no reason why it can’t be done

  3. by johny why on November 16 2009 at 02:31

    conversion to pdf works! pdf-to-png gives me smallest output size.

    but pdf’s larger than about 200 Kb come out distorted. is there any way to control the resolution, color depth, or any other conversion options?

    thanks!

  4. by johny why on November 16 2009 at 02:48

    i’m also finding very large pdf’s (600 Kb, maybe less) don’t get processed at all.

  5. by Elay on November 19 2010 at 15:13

    Hello,how can i convert raw format to jpg and cr2 to jpg? It is possible with phMagick ?

  6. by nuno costa on November 19 2010 at 17:02

    @Elay,

    You can convert to any of imagemagick supported formats

    please see http://www.imagemagick.org/script/formats.php

  7. by des- on December 4 2010 at 00:35

    Hi! Whenever converting a cr2 image to jpg with phMagick it always darkens the result image. Is there any way to avoid the darkening?

  8. by nuno costa on December 6 2010 at 21:16

    @des-

    it only happens with jpg?

    ps: you might get more information on imagemagick site

  9. by des- on December 9 2010 at 15:53

    Tried to convert CR2 to TIF (on 3 different files), same thing happened.

  10. by nuno costa on December 13 2010 at 19:28

    @des

    I’m afraid I can not be of much help, have you tried the imagemagick forums?

    Have you run phMagick in debug mode, maybe imagemagick is complaining about the image format or some values the delegate can not support

  11. by Acácio on July 9 2011 at 16:07

    Muito bom, parabéns e muito obrigado. Como diria Vinicius: “se todos fossem iguais a você”, Colaborativo e generoso em compartilhar seus conhecimentos com aqueles que ainda não sabem.

  12. by oli on July 13 2011 at 11:55

    SVG to PNG/JPEG/GIF support?

  13. by nuno costa on August 1 2011 at 20:49

    It should be supported as long as you have the correct libraries, please check imagemagick.org

  14. by Alex Forey on April 3 2012 at 00:59

    Is there any option to add more parameters? For instance I want to convert an image from png to -ordered-dither h4x4a bitmap, as specified here – http://www.imagemagick.org/Usage/quantize/#halftone, for use with a thermal printer. Thanks.

  15. by eduardo on April 13 2012 at 19:57

    el datelle que descargue el archivo lo intente de ejecutar pero no realiza ninguna accion como la de cambiar formato o rotar

More from francodacosta.com

© francodacosta.com - All rights reserved