/* === S Y N F I G ========================================================= */
-/*! \file main.cpp
+/*! \file tool/main.cpp
** \brief SYNFIG Tool
**
-** $Id: main.cpp,v 1.9 2005/01/23 04:41:10 darco Exp $
+** $Id$
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007, 2008 Chris Moore
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
#include <list>
#include <ETL/clock>
#include <algorithm>
+#include <cstring>
#include <synfig/loadcanvas.h>
#include <synfig/savecanvas.h>
/* === M A C R O S ========================================================= */
+#ifdef ENABLE_NLS
+#undef _
+#define _(x) gettext(x)
+#else
+#undef _
+#define _(x) (x)
+#endif
+
enum exit_code
{
- SYNFIGTOOL_OK =0,
- SYNFIGTOOL_FILENOTFOUND =1,
- SYNFIGTOOL_BORRED =2,
- SYNFIGTOOL_HELP =3,
- SYNFIGTOOL_UNKNOWNARGUMENT =4,
- SYNFIGTOOL_UNKNOWNERROR =5,
- SYNFIGTOOL_INVALIDTARGET =6,
- SYNFIGTOOL_RENDERFAILURE =7,
- SYNFIGTOOL_BLANK =8,
- SYNFIGTOOL_BADVERSION =9,
+ SYNFIGTOOL_OK = 0,
+ SYNFIGTOOL_FILENOTFOUND = 1,
+ SYNFIGTOOL_BORED = 2,
+ SYNFIGTOOL_HELP = 3,
+ SYNFIGTOOL_UNKNOWNARGUMENT = 4,
+ SYNFIGTOOL_UNKNOWNERROR = 5,
+ SYNFIGTOOL_INVALIDTARGET = 6,
+ SYNFIGTOOL_RENDERFAILURE = 7,
+ SYNFIGTOOL_BLANK = 8,
+ SYNFIGTOOL_BADVERSION = 9,
SYNFIGTOOL_MISSINGARGUMENT =10
};
}
virtual bool
- amount_complete(int current, int total)
+ amount_complete(int /*current*/, int /*total*/)
{
return true;
}
int quality;
bool sifout;
+ bool list_canvases;
+
+ bool canvas_info, canvas_info_all, canvas_info_time_start, canvas_info_time_end, canvas_info_frame_rate,
+ canvas_info_frame_start, canvas_info_frame_end, canvas_info_w, canvas_info_h, canvas_info_image_aspect,
+ canvas_info_pw, canvas_info_ph, canvas_info_pixel_aspect, canvas_info_tl, canvas_info_br,
+ canvas_info_physical_w, canvas_info_physical_h, canvas_info_x_res, canvas_info_y_res, canvas_info_span,
+ canvas_info_interlaced, canvas_info_antialias, canvas_info_clamp, canvas_info_flags, canvas_info_focus,
+ canvas_info_bg_color, canvas_info_metadata;
+
+ Job()
+ {
+ canvas_info = canvas_info_all = canvas_info_time_start = canvas_info_time_end = canvas_info_frame_rate = canvas_info_frame_start = canvas_info_frame_end = canvas_info_w = canvas_info_h = canvas_info_image_aspect = canvas_info_pw = canvas_info_ph = canvas_info_pixel_aspect = canvas_info_tl = canvas_info_br = canvas_info_physical_w = canvas_info_physical_h = canvas_info_x_res = canvas_info_y_res = canvas_info_span = canvas_info_interlaced = canvas_info_antialias = canvas_info_clamp = canvas_info_flags = canvas_info_focus = canvas_info_bg_color = canvas_info_metadata = false;
+ };
};
typedef list<String> arg_list_t;
{
cout<<"GUID Test"<<endl;
for(int i=20;i;i--)
- {
cout<<synfig::GUID().get_string()<<' '<<synfig::GUID().get_string()<<endl;
- }
}
void signal_test_func()
cerr<<strprintf(" %s %s %s",flag, arg, spaces+strlen(arg)+strlen(flag)+1)+description<<endl;
else
cerr<<strprintf(" %s %s",flag,spaces+strlen(flag))+description<<endl;
-
}
};
- cerr<<_("syntax: ")<<progname<<" [DEFAULT OPTIONS] ([SIF FILE] [SPECIFIC OPTIONS])..."<<endl;
- cerr<<endl;
- if(amount>=1)
+
+ cerr << endl << _("syntax: ") << progname << " [DEFAULT OPTIONS] ([SIF FILE] [SPECIFIC OPTIONS])..." << endl << endl;
+
+ if(amount == 0)
+ Argument("--help",NULL,_("Print out usage and syntax info"));
+ else
{
Argument("-t","<output type>",_("Specify output target (Default:unknown)"));
Argument("-w","<pixel width>",_("Set the image width (Use zero for file default)"));
Argument("-c","<canvas id>",_("Render the canvas with the given id instead of the root."));
Argument("-o","<output file>",_("Specify output filename"));
Argument("-T","<# of threads>",_("Enable multithreaded renderer using specified # of threads"));
-
Argument("-b",NULL,_("Print Benchmarks"));
-
Argument("--fps","<framerate>",_("Set the frame rate"));
Argument("--time","<time>",_("Render a single frame at <seconds>"));
Argument("--begin-time","<time>",_("Set the starting time"));
+ Argument("--start-time","<time>",_("Set the starting time"));
Argument("--end-time","<time>",_("Set the ending time"));
- Argument("--dpi","<res>",_("Set the dots-per-inch"));
+ Argument("--dpi","<res>",_("Set the physical resolution (dots-per-inch)"));
+ Argument("--dpi-x","<res>",_("Set the physical X resolution (dots-per-inch)"));
+ Argument("--dpi-y","<res>",_("Set the physical Y resolution (dots-per-inch)"));
+
+ Argument("--list-canvases",NULL,_("List the exported canvases in the composition"));
+ Argument("--canvas-info","<fields>",_("Print out specified details of the root canvas"));
Argument("--append","<filename>",_("Append layers in <filename> to composition"));
Argument("--layer-info","<layer>",_("Print out layer's description, parameter info, etc."));
Argument("--signal-test",NULL,_("Test signal implementation"));
#endif
}
- else
- Argument("--help",NULL,_("Print out usage and syntax info"));
cerr<<endl;
}
return SYNFIGTOOL_HELP;
}
-
if(*iter == "--help")
{
display_help(1);
-
return SYNFIGTOOL_HELP;
}
if(*iter == "--info")
{
cout<<PACKAGE"-"VERSION<<endl;
- cout<<"Compiled on "__DATE__ " at "__TIME__;
+ cout<<"Compiled on "__DATE__ /* " at "__TIME__ */;
#ifdef __GNUC__
cout<<" with GCC "<<__VERSION__;
#endif
synfig::Main synfig_main(dirname(progname),&p);
synfig::Layer::Book::iterator iter=synfig::Layer::book().begin();
for(;iter!=synfig::Layer::book().end();iter++)
- cout<<iter->first<<endl;
+ if (iter->second.category != CATEGORY_DO_NOT_USE)
+ cout<<iter->first<<endl;
return SYNFIGTOOL_HELP;
}
Progress p(PACKAGE);
synfig::Main synfig_main(dirname(progname),&p);
iter=next++;
+ if (iter==arg_list.end())
+ {
+ error("The `%s' flag requires a value. Use --help for a list of options.", "--layer-info");
+ return SYNFIGTOOL_MISSINGARGUMENT;
+ }
Layer::Handle layer=synfig::Layer::create(*iter);
cout<<"Layer Name: "<<layer->get_name()<<endl;
cout<<"Localized Layer Name: "<<layer->get_local_name()<<endl;
synfig::Target::Book::iterator iter=synfig::Target::book().begin();
for(;iter!=synfig::Target::book().end();iter++)
cout<<iter->first<<endl;
-
return SYNFIGTOOL_HELP;
}
synfig::LinkableValueNode::Book::iterator iter=synfig::LinkableValueNode::book().begin();
for(;iter!=synfig::LinkableValueNode::book().end();iter++)
cout<<iter->first<<endl;
-
return SYNFIGTOOL_HELP;
}
synfig::Importer::Book::iterator iter=synfig::Importer::book().begin();
for(;iter!=synfig::Importer::book().end();iter++)
cout<<iter->first<<endl;
-
return SYNFIGTOOL_HELP;
}
if(*iter == "--version")
{
cerr<<PACKAGE<<" "<<VERSION<<endl;
-
arg_list.erase(iter);
-
return SYNFIGTOOL_HELP;
}
**\n\
** " << endl << endl;
arg_list.erase(iter);
-
return SYNFIGTOOL_HELP;
}
if(*iter == "-v")
{
verbosity++;
-
arg_list.erase(iter);
-
continue;
}
if(*iter == "-q")
{
be_quiet=true;
-
arg_list.erase(iter);
-
continue;
}
if(*iter == "-b")
{
print_benchmarks=true;
-
arg_list.erase(iter);
-
continue;
}
}
return SYNFIGTOOL_OK;
}
+/* true if the given flag takes an extra parameter */
+bool flag_requires_value(String flag)
+{
+ return (flag=="-a" || flag=="-c" || flag=="-g" || flag=="-h" || flag=="-o" ||
+ flag=="-Q" || flag=="-s" || flag=="-t" || flag=="-T" || flag=="-w" ||
+ flag=="--append" || flag=="--begin-time" || flag=="--canvas-info"|| flag=="--dpi" || flag=="--dpi-x" ||
+ flag=="--dpi-y" || flag=="--end-time" || flag=="--fps" || flag=="--layer-info" || flag=="--start-time" ||
+ flag=="--time" );
+}
+
int extract_arg_cluster(arg_list_t &arg_list,arg_list_t &cluster)
{
arg_list_t::iterator iter, next;
return SYNFIGTOOL_OK;
}
- if(
- *iter=="-t" ||
- *iter=="-w" ||
- *iter=="-h" ||
- *iter=="-a" ||
- *iter=="-g" ||
- *iter=="-o" ||
- *iter=="-s" ||
- *iter=="-Q" ||
- *iter=="-c" ||
- *iter=="--fps" ||
- *iter=="--start-time" ||
- *iter=="--begin-time" ||
- *iter=="--end-time" ||
- *iter=="--start-frame" ||
- *iter=="--end-frame" ||
- *iter=="--time" ||
- *iter=="--frame" ||
- *iter=="--dpi" ||
- *iter=="--dpi-x" ||
- *iter=="--dpi-y" ||
- *iter=="--append" ||
- *iter=="-T" )
+ if (flag_requires_value(*iter))
{
cluster.push_back(*iter);
arg_list.erase(iter);
iter=next++;
- if (iter==arg_list.end()) {
+ if (iter==arg_list.end())
+ {
error("The `%s' flag requires a value. Use --help for a list of options.", cluster.back().c_str());
return SYNFIGTOOL_MISSINGARGUMENT;
}
else if(*iter=="-g")
{
synfig::warning("Gamma argument is currently ignored");
- //arg_list.erase(iter);
- //iter=next++;
+ arg_list.erase(iter);
+ iter=next++;
//desc.set_gamma(Gamma(atof(iter->c_str())));
- //arg_list.erase(iter);
+ arg_list.erase(iter);
}
+ else if (flag_requires_value(*iter))
+ iter=next++;
}
- if(w&&h)
+ if (w||h)
{
+ if (!w)
+ w = desc.get_w() * h / desc.get_h();
+ else if (!h)
+ h = desc.get_h() * w / desc.get_w();
+
desc.set_wh(w,h);
VERBOSE_OUT(1)<<strprintf(_("Resolution set to %dx%d"),w,h)<<endl;
}
- else
- {
- if(w)
- {
- VERBOSE_OUT(1)<<strprintf(_("Width set to %d pixels"),w)<<endl;
- desc.set_w(w);
- }
- if(h)
- {
- VERBOSE_OUT(1)<<strprintf(_("Height set to %d pixels"),h)<<endl;
- desc.set_h(h);
- }
- }
if(span)
desc.set_span(span);
return SYNFIGTOOL_OK;
VERBOSE_OUT(1)<<strprintf(_("Quality set to %d"),quality)<<endl;
arg_list.erase(iter);
}
+ else if (flag_requires_value(*iter))
+ iter=next++;
}
return SYNFIGTOOL_OK;
VERBOSE_OUT(1)<<strprintf(_("Threads set to %d"),threads)<<endl;
arg_list.erase(iter);
}
+ else if (flag_requires_value(*iter))
+ iter=next++;
}
return SYNFIGTOOL_OK;
type=*iter;
arg_list.erase(iter);
}
+ else if (flag_requires_value(*iter))
+ iter=next++;
}
return SYNFIGTOOL_OK;
filename=*iter;
arg_list.erase(iter);
}
+ else if (flag_requires_value(*iter))
+ iter=next++;
}
return SYNFIGTOOL_OK;
arg_list.erase(iter);
ret=SYNFIGTOOL_OK;
}
+ else if (flag_requires_value(*iter))
+ iter=next++;
}
return ret;
canvasid=*iter;
arg_list.erase(iter);
}
+ else if (flag_requires_value(*iter))
+ iter=next++;
}
return SYNFIGTOOL_OK;
}
+int extract_list_canvases(arg_list_t &arg_list,bool &list_canvases)
+{
+ arg_list_t::iterator iter, next;
+
+ for(next=arg_list.begin(),iter=next++;iter!=arg_list.end();iter=next++)
+ if(*iter=="--list-canvases")
+ {
+ list_canvases = true;
+ arg_list.erase(iter);
+ }
+
+ return SYNFIGTOOL_OK;
+}
+
+void extract_canvas_info(arg_list_t &arg_list, Job &job)
+{
+ arg_list_t::iterator iter, next;
+
+ for(next=arg_list.begin(),iter=next++;iter!=arg_list.end();iter=next++)
+ if(*iter=="--canvas-info")
+ {
+ job.canvas_info = true;
+ arg_list.erase(iter);
+ iter=next++;
+ String values(*iter), value;
+ arg_list.erase(iter);
+
+ std::string::size_type pos;
+ while (!values.empty())
+ {
+ pos = values.find_first_of(',');
+ if (pos == std::string::npos)
+ {
+ value = values;
+ values = "";
+ }
+ else
+ {
+ value = values.substr(0, pos);
+ values = values.substr(pos+1);
+ }
+ if (value == "all")
+ {
+ job.canvas_info_all = true;
+ return;
+ }
+
+ if (value == "time_start") job.canvas_info_time_start = true;
+ else if (value == "time_end") job.canvas_info_time_end = true;
+ else if (value == "frame_rate") job.canvas_info_frame_rate = true;
+ else if (value == "frame_start") job.canvas_info_frame_start = true;
+ else if (value == "frame_end") job.canvas_info_frame_end = true;
+ else if (value == "w") job.canvas_info_w = true;
+ else if (value == "h") job.canvas_info_h = true;
+ else if (value == "image_aspect") job.canvas_info_image_aspect = true;
+ else if (value == "pw") job.canvas_info_pw = true;
+ else if (value == "ph") job.canvas_info_ph = true;
+ else if (value == "pixel_aspect") job.canvas_info_pixel_aspect = true;
+ else if (value == "tl") job.canvas_info_tl = true;
+ else if (value == "br") job.canvas_info_br = true;
+ else if (value == "physical_w") job.canvas_info_physical_w = true;
+ else if (value == "physical_h") job.canvas_info_physical_h = true;
+ else if (value == "x_res") job.canvas_info_x_res = true;
+ else if (value == "y_res") job.canvas_info_y_res = true;
+ else if (value == "span") job.canvas_info_span = true;
+ else if (value == "interlaced") job.canvas_info_interlaced = true;
+ else if (value == "antialias") job.canvas_info_antialias = true;
+ else if (value == "clamp") job.canvas_info_clamp = true;
+ else if (value == "flags") job.canvas_info_flags = true;
+ else if (value == "focus") job.canvas_info_focus = true;
+ else if (value == "bg_color") job.canvas_info_bg_color = true;
+ else if (value == "metadata") job.canvas_info_metadata = true;
+ else
+ {
+ cerr<<_("Unrecognised canvas variable: ") << "'" << value << "'" << endl;
+ cerr<<_("Recognized variables are:") << endl <<
+ " all, time_start, time_end, frame_rate, frame_start, frame_end, w, h," << endl <<
+ " image_aspect, pw, ph, pixel_aspect, tl, br, physical_w, physical_h," << endl <<
+ " x_res, y_res, span, interlaced, antialias, clamp, flags," << endl <<
+ " focus, bg_color, metadata" << endl;
+ }
+
+ if (pos == std::string::npos)
+ break;
+ };
+ }
+}
+
+void list_child_canvases(string prefix, Canvas::Handle canvas)
+{
+ Canvas::Children children(canvas->children());
+ for (Canvas::Children::iterator iter = children.begin(); iter != children.end(); iter++)
+ {
+ cout << prefix << ":" << (*iter)->get_id() << endl;
+ list_child_canvases(prefix + ":" + (*iter)->get_id(), *iter);
+ }
+}
+
+void list_canvas_info(Job job)
+{
+ Canvas::Handle canvas(job.canvas);
+ const RendDesc &rend_desc(canvas->rend_desc());
+
+ if (job.canvas_info_all || job.canvas_info_time_start)
+ {
+ cout << endl << "# " << _("Start Time") << endl;
+ cout << "time_start" << "=" << rend_desc.get_time_start().get_string().c_str() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_time_end)
+ {
+ cout << endl << "# " << _("End Time") << endl;
+ cout << "time_end" << "=" << rend_desc.get_time_end().get_string().c_str() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_frame_rate)
+ {
+ cout << endl << "# " << _("Frame Rate") << endl;
+ cout << "frame_rate" << "=" << rend_desc.get_frame_rate() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_frame_start)
+ {
+ cout << endl << "# " << _("Start Frame") << endl;
+ cout << "frame_start" << "=" << rend_desc.get_frame_start() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_frame_end)
+ {
+ cout << endl << "# " << _("End Frame") << endl;
+ cout << "frame_end" << "=" << rend_desc.get_frame_end() << endl;
+ }
+
+ if (job.canvas_info_all)
+ cout << endl;
+
+ if (job.canvas_info_all || job.canvas_info_w)
+ {
+ cout << endl << "# " << _("Width") << endl;
+ cout << "w" << "=" << rend_desc.get_w() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_h)
+ {
+ cout << endl << "# " << _("Height") << endl;
+ cout << "h" << "=" << rend_desc.get_h() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_image_aspect)
+ {
+ cout << endl << "# " << _("Image Aspect Ratio") << endl;
+ cout << "image_aspect" << "=" << rend_desc.get_image_aspect() << endl;
+ }
+
+ if (job.canvas_info_all)
+ cout << endl;
+
+ if (job.canvas_info_all || job.canvas_info_pw)
+ {
+ cout << endl << "# " << _("Pixel Width") << endl;
+ cout << "pw" << "=" << rend_desc.get_pw() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_ph)
+ {
+ cout << endl << "# " << _("Pixel Height") << endl;
+ cout << "ph" << "=" << rend_desc.get_ph() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_pixel_aspect)
+ {
+ cout << endl << "# " << _("Pixel Aspect Ratio") << endl;
+ cout << "pixel_aspect" << "=" << rend_desc.get_pixel_aspect() << endl;
+ }
+
+ if (job.canvas_info_all)
+ cout << endl;
+
+ if (job.canvas_info_all || job.canvas_info_tl)
+ {
+ cout << endl << "# " << _("Top Left") << endl;
+ cout << "tl" << "=" << rend_desc.get_tl()[0]
+ << " " << rend_desc.get_tl()[1] << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_br)
+ {
+ cout << endl << "# " << _("Bottom Right") << endl;
+ cout << "br" << "=" << rend_desc.get_br()[0]
+ << " " << rend_desc.get_br()[1] << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_physical_w)
+ {
+ cout << endl << "# " << _("Physical Width") << endl;
+ cout << "physical_w" << "=" << rend_desc.get_physical_w() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_physical_h)
+ {
+ cout << endl << "# " << _("Physical Height") << endl;
+ cout << "physical_h" << "=" << rend_desc.get_physical_h() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_x_res)
+ {
+ cout << endl << "# " << _("X Resolution") << endl;
+ cout << "x_res" << "=" << rend_desc.get_x_res() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_y_res)
+ {
+ cout << endl << "# " << _("Y Resolution") << endl;
+ cout << "y_res" << "=" << rend_desc.get_y_res() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_span)
+ {
+ cout << endl << "# " << _("Diagonal Image Span") << endl;
+ cout << "span" << "=" << rend_desc.get_span() << endl;
+ }
+
+ if (job.canvas_info_all)
+ cout << endl;
+
+ if (job.canvas_info_all || job.canvas_info_interlaced)
+ {
+ cout << endl << "# " << _("Interlaced") << endl;
+ cout << "interlaced" << "=" << rend_desc.get_interlaced() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_antialias)
+ {
+ cout << endl << "# " << _("Antialias") << endl;
+ cout << "antialias" << "=" << rend_desc.get_antialias() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_clamp)
+ {
+ cout << endl << "# " << _("Clamp") << endl;
+ cout << "clamp" << "=" << rend_desc.get_clamp() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_flags)
+ {
+ cout << endl << "# " << _("Flags") << endl;
+ cout << "flags" << "=" << rend_desc.get_flags() << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_focus)
+ {
+ cout << endl << "# " << _("Focus") << endl;
+ cout << "focus" << "=" << rend_desc.get_focus()[0]
+ << " " << rend_desc.get_focus()[1] << endl;
+ }
+
+ if (job.canvas_info_all || job.canvas_info_bg_color)
+ {
+ cout << endl << "# " << _("Background Color") << endl;
+ cout << "bg_color" << "=" << rend_desc.get_bg_color().get_string().c_str() << endl;
+ }
+
+ if (job.canvas_info_all)
+ cout << endl;
+
+ if (job.canvas_info_all || job.canvas_info_metadata)
+ {
+ std::list<String> keys(canvas->get_meta_data_keys());
+ cout << endl << "# " << _("Metadata") << endl;
+ for (std::list<String>::iterator iter = keys.begin(); iter != keys.end(); iter++)
+ cout << *iter << "=" << canvas->get_meta_data(*iter) << endl;
+ }
+}
+
/* === M E T H O D S ======================================================= */
/* === E N T R Y P O I N T ================================================= */
arg_list_t arg_list;
job_list_t job_list;
+ setlocale(LC_ALL, "");
+
+#ifdef ENABLE_NLS
+ bindtextdomain("synfig", LOCALEDIR);
+ textdomain("synfig");
+#endif
+
progname=argv[0];
Progress p(argv[0]);
cerr<<_("FATAL: Synfig Version Mismatch")<<endl;
return SYNFIGTOOL_BADVERSION;
}
+
if(argc==1)
{
display_help(0);
return ret;
// Open the composition
- {
- job_list.front().root=open_canvas(job_list.front().filename);
- }
+ job_list.front().root=open_canvas(job_list.front().filename);
+
if(!job_list.front().root)
{
cerr<<_("Unable to open ")<<job_list.front().filename<<"."<<endl;
continue;
}
+ bool list_canvases = false;
+ extract_list_canvases(imageargs, list_canvases);
+ job_list.front().list_canvases = list_canvases;
+
+ extract_canvas_info(imageargs, job_list.front());
+
job_list.front().root->set_time(0);
string canvasid;
cerr<<_("Throwing out job...")<<endl;
job_list.pop_front();
continue;
-
}
}
else
}
VERBOSE_OUT(2)<<_("Appended contents of ")<<composite_file<<endl;
}
- }while(false);
+ } while(false);
VERBOSE_OUT(4)<<_("Attempting to determine target/outfile...")<<endl;
// If the target type is not yet defined,
// try to figure it out from the outfile.
if(target_name.empty() && !job_list.front().outfilename.empty())
- try
{
VERBOSE_OUT(3)<<_("Target name undefined, attempting to figure it out")<<endl;
- string ext=string(find(job_list.front().outfilename.begin(),job_list.front().outfilename.end(),'.')+1,job_list.front().outfilename.end());
+ string ext = filename_extension(job_list.front().outfilename);
+ if (ext.length()) ext = ext.substr(1);
if(Target::ext_book().count(ext))
+ {
target_name=Target::ext_book()[ext];
+ info("target name not specified - using %s", target_name.c_str());
+ }
else
- target_name=ext;
- }
- catch(std::length_error)
- {
- synfig::warning("Length error caught when attempting to figure out target name");
+ {
+ string lower_ext(ext);
+
+ for(unsigned int i=0;i<ext.length();i++)
+ lower_ext[i] = tolower(ext[i]);
+
+ if(Target::ext_book().count(lower_ext))
+ {
+ target_name=Target::ext_book()[lower_ext];
+ info("target name not specified - using %s", target_name.c_str());
+ }
+ else
+ target_name=ext;
+ }
}
// If the target type is STILL not yet defined, then
// given input filename. (ie: change the extension)
if(job_list.front().outfilename.empty())
{
- job_list.front().outfilename=job_list.front().filename;
- job_list.front().outfilename.erase(find(job_list.front().outfilename.begin(),job_list.front().outfilename.end(),'.'),job_list.front().outfilename.end());
- job_list.front().outfilename+='.';
+ job_list.front().outfilename = filename_sans_extension(job_list.front().filename) + '.';
if(Target::book().count(target_name))
job_list.front().outfilename+=Target::book()[target_name].second;
else
job_list.front().target=synfig::Target::create(target_name,job_list.front().outfilename);
if(target_name=="sif")
- {
job_list.front().sifout=true;
- }
else
{
if(!job_list.front().target)
// Set the threads for the target
if(job_list.front().target && Target_Scanline::Handle::cast_dynamic(job_list.front().target))
- {
Target_Scanline::Handle::cast_dynamic(job_list.front().target)->set_threads(threads);
- }
if(imageargs.size())
{
job_list.pop_front();
continue;
}
- //string bleh;
- //getline(cin,bleh);
}
}
if(!job_list.size())
{
cerr<<_("Nothing to do!")<<endl;
- return SYNFIGTOOL_BORRED;
+ return SYNFIGTOOL_BORED;
}
for(;job_list.size();job_list.pop_front())
RenderProgress p;
p.task(job_list.front().filename+" ==> "+job_list.front().outfilename);
- if(!job_list.front().sifout)
+ if(job_list.front().sifout)
{
- VERBOSE_OUT(1)<<_("Rendering...")<<endl;
- etl::clock timer;
- timer.reset();
- // Call the render member of the target
- if(!job_list.front().target->render(&p))
+ if(!save_canvas(job_list.front().outfilename,job_list.front().canvas))
{
cerr<<"Render Failure."<<endl;
return SYNFIGTOOL_RENDERFAILURE;
}
- if(print_benchmarks)
- {
- cout<<job_list.front().filename+": Rendered in "<<timer()<<" seconds."<<endl;
- }
+ }
+ else if (job_list.front().list_canvases)
+ {
+ list_child_canvases(job_list.front().filename + "#", job_list.front().canvas);
+ cerr << endl;
+ }
+ else if (job_list.front().canvas_info)
+ {
+ list_canvas_info(job_list.front());
+ cerr << endl;
}
else
{
- if(!save_canvas(job_list.front().outfilename,job_list.front().canvas))
+ VERBOSE_OUT(1)<<_("Rendering...")<<endl;
+ etl::clock timer;
+ timer.reset();
+ // Call the render member of the target
+ if(!job_list.front().target->render(&p))
{
cerr<<"Render Failure."<<endl;
return SYNFIGTOOL_RENDERFAILURE;
}
+ if(print_benchmarks)
+ cout<<job_list.front().filename+": Rendered in "<<timer()<<" seconds."<<endl;
}
}