bump to 7.21, im_system_image works

This commit is contained in:
John Cupitt 2010-01-15 14:22:11 +00:00
parent 2f0a6ab66b
commit 1861c82cf6
6 changed files with 41 additions and 49 deletions

View File

@ -6,7 +6,7 @@ AC_CONFIG_MACRO_DIR(m4)
# user-visible library versioning
IM_MAJOR_VERSION=7
IM_MINOR_VERSION=21
IM_MICRO_VERSION=0
IM_MICRO_VERSION=1
IM_VERSION=$IM_MAJOR_VERSION.$IM_MINOR_VERSION.$IM_MICRO_VERSION
IM_VERSION_STRING=$IM_VERSION-`date`
@ -23,7 +23,7 @@ PACKAGE=vips
# interface changes not backwards compatible?: reset age to 0
LIBRARY_CURRENT=28
LIBRARY_REVISION=2
LIBRARY_REVISION=3
LIBRARY_AGE=13
AM_INIT_AUTOMAKE($PACKAGE,$VERSION)

View File

@ -63,11 +63,6 @@
#define IM_MAX_STRSIZE (4096)
#ifdef OS_WIN32
#define popen(b,m) _popen(b,m)
#define pclose(f) _pclose(f)
#endif /*OS_WIN32*/
/* Run a command on an IMAGE ... copy to tmp (if necessary), run
* command on it, unlink (if we copied), return stdout from command.
*/

View File

@ -53,18 +53,12 @@
#define IM_MAX_STRSIZE (4096)
#ifdef OS_WIN32
#define popen(b,m) _popen(b,m)
#define pclose(f) _pclose(f)
#endif /*OS_WIN32*/
static int
system_image( IMAGE *im,
IMAGE *in_image, IMAGE *out_image, const char *cmd_format,
IMAGE *in_image, char *out_name, const char *cmd_format,
char **log )
{
const char *in_name = in_image->filename;
const char *out_name = out_image->filename;
FILE *fp;
char line[IM_MAX_STRSIZE];
char txt[IM_MAX_STRSIZE];
@ -84,42 +78,29 @@ system_image( IMAGE *im,
if( log )
*log = im_strdup( NULL, vips_buf_all( &buf ) );
if( !result ) {
IMAGE *t;
if( !(t = im_open_local( out_image, out_name, "r" )) ||
im_copy( t, out_image ) )
return( -1 );
}
return( result );
}
/**
* im_system_image:
Run a command on an image, returning a new image.
Run a command on an image, returning a new image. Eg.:
"mycommand --dostuff %s -o %s"
have separate format strings for input and output?
"%s.jpg"
im_system_image A2 "%s.jpg" "%s.jpg" "convert %s -swirl 45 %s"
Actions:
- create two empty temporary files
- write the image to the first
- create two temporary file names using the passed format strings to set type
= expand the command, using the two expanded filenames
- write the image to the first filename
- call system() on the expanded command
- capture stdout/stderr into log
- capture stdout into log
- delete the temp input file
- open the output image (the output file will be auto deleted when this
IMAGE is closed.
- return the output filename, or NULL if the command failed (log is still
set in this case)
The caller would open the output file, either with im_open(), or with it's
own system (nip2 has it's own open file thing to give progress feedback and
use disc for format conversion), and be responsible for deleting the temp output file at some point.
*/
IMAGE *
@ -128,25 +109,41 @@ im_system_image( IMAGE *im,
char **log )
{
IMAGE *in_image;
IMAGE *out_image;
char *out_name;
IMAGE *out;
if( log )
*log = NULL;
if( !(in_image = im__open_temp( in_format )) )
return( NULL );
if( !(out_image = im__open_temp( out_format )) ) {
if( !(out_name = im__temp_name( out_format )) ) {
im_close( in_image );
return( NULL );
}
if( system_image( im, in_image, out_image, cmd_format, log ) ) {
im_close( out_image );
if( system_image( im, in_image, out_name, cmd_format, log ) ) {
im_close( in_image );
g_free( out_name );
return( NULL );
}
im_close( in_image );
return( out_image );
if( !(out = im_open( out_name, "r" )) ) {
g_free( out_name );
return( NULL );
}
if( im_add_postclose_callback( out,
(im_callback_fn) unlink, out->filename, NULL ) ) {
g_free( out_name );
im_close( out );
g_unlink( out_name );
return( NULL );
}
g_free( out_name );
return( out );
}

View File

@ -28,8 +28,8 @@
*/
/*
*/
#define DEBUG
*/
#ifdef HAVE_CONFIG_H
#include <config.h>

Binary file not shown.

View File

@ -5,7 +5,7 @@ msgid ""
msgstr ""
"Project-Id-Version: vips 7.20.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-01-14 21:04+0000\n"
"POT-Creation-Date: 2010-01-15 13:45+0000\n"
"PO-Revision-Date: Thu Nov 26 12:08:20 GMT 2009\n"
"Last-Translator: john <jcupitt@gmail.com>\n"
"Language-Team: \n"
@ -1809,7 +1809,7 @@ msgstr ""
msgid "func already attached"
msgstr ""
#: libvips/iofuncs/im_generate.c:684 libvips/iofuncs/im_prepare.c:184
#: libvips/iofuncs/im_generate.c:689 libvips/iofuncs/im_prepare.c:184
#: libvips/iofuncs/im_prepare.c:404
#, c-format
msgid "unable to input from a %s image"
@ -1857,7 +1857,7 @@ msgstr ""
msgid "flag not 0,1,2"
msgstr ""
#: libvips/iofuncs/im_close.c:199
#: libvips/iofuncs/im_close.c:201
#, c-format
msgid "unable to close fd for %s"
msgstr ""
@ -2278,28 +2278,28 @@ msgstr ""
msgid "no such string field \"%s\""
msgstr ""
#: libvips/iofuncs/im_open.c:314
#: libvips/iofuncs/im_open.c:316
#, c-format
msgid "%s %s: %d%% complete"
msgstr ""
#. Spaces at end help to erase the %complete message we overwrite.
#.
#: libvips/iofuncs/im_open.c:332
#: libvips/iofuncs/im_open.c:334
#, c-format
msgid "%s %s: done in %ds \n"
msgstr ""
#: libvips/iofuncs/im_open.c:419
#: libvips/iofuncs/im_open.c:421
msgid "NULL filename or mode"
msgstr ""
#: libvips/iofuncs/im_open.c:468
#: libvips/iofuncs/im_open.c:470
#, fuzzy, c-format
msgid "unsupported filetype \"%s\""
msgstr "unsupported colourspace %d"
#: libvips/iofuncs/im_open.c:484
#: libvips/iofuncs/im_open.c:486
#, c-format
msgid "bad mode \"%s\""
msgstr ""