-
-
Notifications
You must be signed in to change notification settings - Fork 649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow spaces in image array filenames #1493
Comments
Sorry, I don't think that's possible at the libvips CLI right now. You'll need to use something like Python. Let's leave this issue open as an enhancement. |
(something like python, php, ruby, etc. should give you much better performance and IO behaviour too, so it might be worth investigating anyway) |
I`ll try out ruby-vips. |
Supporting \ as an escape character in strings should be simple. It's just this function: https://github.com/libvips/libvips/blob/master/libvips/iofuncs/type.c#L1292 |
Similar problem I`ve experienced when I wanted to use vips write_to_file. But ruby-vips worked as intended, I achieved solution |
/* compile with:
* gcc try305.c -g -Wall `pkg-config vips --cflags --libs`
*/
#include <vips/vips.h>
#define SIZE (100)
int
main( int argc, char **argv )
{
VipsImage *image;
int x, y, z;
VipsPel *mem;
if( VIPS_INIT( argv[0] ) )
vips_error_exit( NULL );
/* SIZE x SIZE rgba image.
*/
if( !(mem = VIPS_ARRAY( NULL, 4 * SIZE * SIZE, VipsPel )) )
vips_error_exit( NULL );
for( y = 0; y < SIZE; y++ )
for( x = 0; x < SIZE; x++ )
for( z = 0; z < 4; z++ )
mem[y * 4 * SIZE + x * 4 + z] = 2 * (x + y + z);
/* Wrap up as a 4-band VipsImage.
*/
if( !(image = vips_image_new_from_memory( mem, 4 * SIZE * SIZE,
SIZE, SIZE, 4, VIPS_FORMAT_UCHAR )) )
vips_error_exit( NULL );
if( vips_image_write_to_file( image,
"this is a filename with spaces.png", NULL ) )
vips_error_exit( NULL );
g_object_unref( image );
g_free( mem );
return( 0 );
} I see:
|
Yes, that's the case. |
So: vips_break_token( "hello\ world", " " ) Sees a single token, `"hello world"`. This means you can now do things like: $ vips arrayjoin "k\ 2.jpg" x.png Where "k 2.jpg" is a filename containing a space. See #1493
OK, this works now:
Where
Sets a profile from a file called Thanks for the suggestion! |
Very useful. Thanks for update. |
And on windows where the backslash itself is a directory seperator, how to differentiate it in the path? |
You can use a double backslash, eg.:
|
Hi, i'm failing to get a simple test file with a space to be found by vips... etc |
What's the exact command you are trying to run? I see:
|
powershell: cmd: I right clicked on the file itself to confirm its existence -> copy path, and it gives the path: "D:\temp\BKLXSC 1696099971.tiff"
|
I tried in psh as well, it all seems to work here:
|
I tried with tiffs and drive letters and that works too:
|
There are two different ways of quoting backslash and space because there are two different things interpreting them. In plain command-line arguments, just use space and put the whole thing in quotes. PSH doesn't use backslash as escape, so you don't need to quote it:
I agree, it's confusing :( If you use something like python, all this shell craziness goes away. |
I came right, your examples helped, I was doing everything except the right thing, embarrassed |
I am trying to composite few images, but I need to use paths with spaces. How Can I escape them to use with vips command line?
Standard shell space escaping is not working.
vips composite "backgrounds\ additional/top.png backgrounds\ additional/bottom.png central.png" out.png 2 --x "3 10" --y "1 20"
This command is not working either, because vips splits array by spaces.
vips composite "backgrounds additional/top.png backgrounds additional/bottom.png central.png" out.png 2 --x "3 10" --y "1 20"
This command is not working, becuase ' is used explicitly
vips composite "'backgrounds additional/top.png' 'backgrounds additional/bottom.png' central.png" out.png 2 --x "3 10" --y "1 20"
The text was updated successfully, but these errors were encountered: