Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0

    Unhappy Problem converting svg to png


    Hi all,

    I was trying to convert svg to png file using imagemagick. But the font family is not shown correctly after conversion.

    the php code I use is
    exec("convert -background none path/to/file/test.svg path/to/file/test.png);

    whatever the font family in the svg file is, the png file will always show text in "Arial" font. Could anybody tell me how to fix that? Thanks.
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,692
    Rep Power
    6351
    imagemagick has nothing to do with PHP (and the code you've pasted is invalid). The imagemagick help boards will be better for you.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0
    Originally Posted by ManiacDan
    imagemagick has nothing to do with PHP (and the code you've pasted is invalid). The imagemagick help boards will be better for you.
    But I did got the svg converted except the font.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    165
    Rep Power
    18
    yes the above code is in fact "valid" the exec command like a few other simmilar commands in php posts a shell command to the operating system. However it is nothing with your php that needs help with at this point, you need support using the linux/unix application imagemagic
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    165
    Rep Power
    18
    However you may want to use the system() command at least while debugging as it will return output from the shell.

    Originally Posted by portcitysoftwar
    yes the above code is in fact "valid" the exec command like a few other simmilar commands in php posts a shell command to the operating system. However it is nothing with your php that needs help with at this point, you need support using the linux/unix application imagemagic
  10. #6
  11. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,692
    Rep Power
    6351
    yes the above code is in fact "valid" the exec command like a few other simmilar commands in php posts a shell command to the operating system.
    Except the code is not, in fact, valid, since it's missing a closing double-quote.


    However you may want to use the system() command at least while debugging as it will return output from the shell.
    System OUTPUTS the results directly to the screen, whereas exec() optionally returns the results as an array of lines.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0
    Originally Posted by portcitysoftwar
    However you may want to use the system() command at least while debugging as it will return output from the shell.
    Ok. Thank you. Could you tell me a way to convert svg to png then?
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    165
    Rep Power
    18
    sorry missed the quotations. I recommended system while debugging just so he could see the result to see if imagemagic was throwing any errors to the shell.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    165
    Rep Power
    18
    You could try using the imagemagic php extension
    PHP Code:
    $image = new Imagick();
    $image->readImageBlob(file_get_contents('image.svg'));
    $image->setImageFormat("png24");
    $image->resizeImage(1024768imagick::FILTER_LANCZOS1); 
    $image->writeImage('image.png'
    Originally Posted by portcitysoftwar
    sorry missed the quotations. I recommended system while debugging just so he could see the result to see if imagemagic was throwing any errors to the shell.
  18. #10
  19. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,692
    Rep Power
    6351
    Originally Posted by CharlesDou
    Ok. Thank you. Could you tell me a way to convert svg to png then?
    Are you not understanding what we're saying? imagemagick is NOT PHP. We don't know your answer. Use system() or the second argument to exec() to see if your copy of imagemagick is throwing an error. If it is, move on from there. if not, find the imagemagick message board.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    165
    Rep Power
    18
    well their is the imagemagic extension of php but it does the same thing and just passes arguments to the shell i do believe.

    however your other option would be another conversion library like Apache BATIK Svg Rasterizer
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0
    Originally Posted by portcitysoftwar
    well their is the imagemagic extension of php but it does the same thing and just passes arguments to the shell i do believe.

    however your other option would be another conversion library like Apache BATIK Svg Rasterizer
    Thank you for all the replies. I just used the system function to execute the command and it returns 0.

    I did use BATIK before but it is too slow.
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    165
    Rep Power
    18
    PHP Code:

    <?php
    $yourCommand
    ="YOUR COMMAND HERE";
    echo 
    '<pre>';

    // Outputs all the result of shellcommand "ls", and returns
    // the last output line into $last_line. Stores the return value
    // of the shell command in $retval.
    $last_line system($yourCommand$retval);

    // Printing additional info
    echo '
    </pre>
    <hr />Last line of the output: ' 
    $last_line '
    <hr />Return value: ' 
    $retval;
    ?>
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    165
    Rep Power
    18
    try the actual Imagick php extension if that doesnt work then their is really nothing the php guys can help you with as it is an imagemagick application issue. But you may want to make sure you have the correct fonts installled on your system. that should always be the first thing to check when it is defaulting back to arial
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    165
    Rep Power
    18
    try the actual Imagick php extension if that doesnt work then their is really nothing the php guys can help you with as it is an imagemagick application issue. But you may want to make sure you have the correct fonts installled on your system. that should always be the first thing to check when it is defaulting back to arial
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo