#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    12
    Rep Power
    0

    Php -> call C program -> return .png to php


    So, I am creating a web-based application where a php file needs to call a C file with a set of parameters. These will be a set of .png file locations

    Say this symbol represents the images '[]'

    What I need the C program to do is load the images from their directory into memory (this directory will be on the same web server as the C program). What I need the program to then do is compile these loaded images together like this [][][][]. So basically, the files will have the same height and width, and I want the C program to put them all horizontally next to one another and then produce a large .png file with this new multiple-image file.

    How could I go about doing this?

    Thanks :),

    -James
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,379
    Rep Power
    1871
    http://cf.ccmr.cornell.edu/cgi-bin/w...eMagick%281%29
    Perhaps it would be easier to make your php program invoke the 'montage' sub-program of the ImageMagick suite.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    12
    Rep Power
    0
    Originally Posted by salem
    http://cf.ccmr.cornell.edu/cgi-bin/w...eMagick%281%29
    Perhaps it would be easier to make your php program invoke the 'montage' sub-program of the ImageMagick suite.
    Thanks for that!

    Will this be much slower though? Thing is, this file will be called very often and on most pages on my site; it needs to be quite speedy and should be able to combine about 15 images quite quickly
  6. #4
  7. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,379
    Rep Power
    1871
    I'm sure you could gain an edge by
    - only dealing with PNG files
    - only dealing with files which have the same dimensions
    - only dealing with a single output layout.

    How much of an edge - hard to say. ImageMagick is already written in C or C++ to begin with, so you're not going to get a huge win. Factor in that it is already bug free and probably optimised to an extent anyway.

    So you're looking at
    - a few hours to figure out the exact command line to pass to montage.
    vs
    - several weeks of reading libpng manual, finding out how the API works, writing code to parse arguments, read files, create a new image etc etc, and debugging it.

    I suggest you go with the choice 1 and actually measure some performance before embarking on choice 2.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    12
    Rep Power
    0
    Originally Posted by salem
    I'm sure you could gain an edge by
    - only dealing with PNG files
    - only dealing with files which have the same dimensions
    - only dealing with a single output layout.

    How much of an edge - hard to say. ImageMagick is already written in C or C++ to begin with, so you're not going to get a huge win. Factor in that it is already bug free and probably optimised to an extent anyway.

    So you're looking at
    - a few hours to figure out the exact command line to pass to montage.
    vs
    - several weeks of reading libpng manual, finding out how the API works, writing code to parse arguments, read files, create a new image etc etc, and debugging it.

    I suggest you go with the choice 1 and actually measure some performance before embarking on choice 2.
    Thanks very much!! I'll give imageMagick a shot.

IMN logo majestic logo threadwatch logo seochat tools logo