Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
syntax advice
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Chase James  
View profile  
 More options Aug 1 2011, 11:28 am
From: Chase James <chaseaja...@gmail.com>
Date: Mon, 1 Aug 2011 11:28:25 -0400
Local: Mon, Aug 1 2011 11:28 am
Subject: syntax advice

I'm writing an Erlang wrapper for GraphicsMagick, but I'm not sure of which
way to go with the library's syntax.

The first example is more like the gm command itself, where command
arguments are set in one go and the command is run.

The second example is like each command is added to a running queue (stored
in the record created by "gm:new"), where the command is finally processed
and executed by "gm:write".

I was thinking about making the API clean enough so I could support both
methods...

% POSSIBLE SYNTAX 1
gm:convert("/some/image.jpg", "/something/crazy.jpg", [
  flip,
  magnify,
  {rotate, "green", 45},
  {blur, 7, 3},
  {crop, 300, 300, 150, 130},
  {edge, 3}
]).

% Getting width and height of image using Syntax 1 (returns an img_info
record)
Info = gm:identify("/some/image.jpg", [width, height]),
W = Info#img_info.width,
H = Info#img_info.height.

% Cropping an image with Syntax 1
gm:convert("/some/image.jpg", "/something/cropped.jpg", [{crop, 300, 300,
150, 130}]).

% POSSIBLE SYNTAX 2
I1 = gm:new("/some/image.jpg"), % creates the img record
I2 = gm:flip(I1),
I3 = gm:magnify(I2),
I4 = gm:rotate(I3, "green", 45),
I5 = gm:blur(I4, 7, 3),
I6 = gm:crop(I5, 300, 300, 150, 130),
I7 = gm:edge(I6, 3),
gm:write(I7, "/something/crazy.jpg").

% Get width of image using Syntax 2
I8 = gm:identify(I7),
gm:width(I8).

% SYNTAX 2 (Crop an image on one line)
gm:write(gm:crop(gm:new("/some/image.jpg"), 200, 200),
"/something/cropped.jpg").

Any advice?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »