Menu
+

About Get Support

Live Updates: Post Numbered as #2 4/12/17

Okay so,

I don’t remember falling asleep. I just did. I fumbled around with my set up on one of the test scripts and had 3 ideas I was going to try. First, I copied it wrong, and I was going to read the comments to check for anything I might’ve missed. 2nd, the make check command on the top level directory went through all the demos and got a passing score. So, have a look at the make check portion of that Makefile to see how the developers are doing it (but that’s for the shell script and not the magick++ portion?). Finally 3rd, I already forgot what the 3rd route was in my head. I played around with the first one a bit and after 10minutes it worked. I don’t like it though. I’m using that “helpful” Magick++-config shell script the developers included with the backquotes in my command line. I’m not used to doing this. Anyways, the test code makes a c++ program that if you run it creates a logo.png file. Now, I’m working on a make file that incorporates the Magick++-config shell script. This means that the shell script needs to be in the directory I’m working on or linked to in the PATH. Again, this feels like an extra step. Traditionally I would have a list of all the flags my program needs and then just hardwire those into my Makefile. The script seems to work for now though. Below is the raw test code that I’m running. Shamelessly copy and pasted.

#include <Magick++.h> 
#include <iostream> 

using namespace std; 
using namespace Magick; 

int main(int argc,char **argv) 
{ 
  InitializeMagick(*argv);

  // Construct the image object. Seperating image construction from the 
  // the read operation ensures that a failure to read the image file 
  // doesn't render the image object useless. 
  Image image;
  try { 
    // Read a file into image object 
    image.read( "logo:" );

    // Crop the image to specified size (width, height, xOffset, yOffset)
    image.crop( Geometry(100,100, 100, 100) );

    // Write the image to a file 
    image.write( "logo.png" ); 
  } 
  catch( Exception &error_ ) 
    { 
      cout << "Caught exception: " << error_.what() << endl; 
      return 1; 
    } 
  return 0; 
}

To get it to run, you need this in its own directory, alongside with the executable shell script Magick++-config. If it’s not executable use that chmod magic. Then just vim Makefile what I wrote below

CC = g++ 
FLAGS = `Magick++-config --cppflags --cxxflags --ldflags --libs` 
 
all: 
  $(CC) $(FLAGS) -o resoScript.exe resoScript.cpp 
  
clean: 
  rm *.png *.exe

my cpp compile is g++, change it to your own. To run this bad boy simply invoke make. then run ./resoScript.exe to run the newly created executable and it will create the logo.png file. To restart everything, just invoke make clean and the rm commands you see above will delete the 2 files all in one go. Generically speaking, any filename that ends in .png or .exe inside the directory will be targeted. With this, you can make changes to resoScript.cpp and destroy what you make quickly and go back and forth without having to do a lot of typing. If you keep a separate window opened to the directory on your multi-screen terminal, just press the up arrow to go back to the previous command. This make files assume that your renamed the provided test code as resoScript.cpp. This is the template, I’ll be using for this little project. Again, as mentioned in last night’s post, having those back quotes expresses the command that’s in between them. If you use forward quotes, the computer is going to wonder why you’re putting down a string. There should be a way to remove the Magick++-config shell script all together, but I wonder if the developers of that script thought it would make the wrapper library more machine agnostic? Anyways, it works. Time to expand on this little program. I should stress this, at this point, my only contribution to this is the makefile. Hopefully someone out there finds it useful. You could just type it all out by hand (every single time), but this way it’s just 2 buttons, the up-arrow then enter.

===

update. I went to check on my nursery, and 3 of my seeds just germinated! OMG!!! ^_^ taking photos. Will update in a future blog post