xinxinlx / openjpeg

Automatically exported from code.google.com/p/openjpeg
Other
0 stars 0 forks source link

Allow opj_compress and opj_decompress to read/write images over stdin/stdout #224

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.piping openjepg with another applivcation BEFORE it
2.application sent picture to STDOUT
3.image_to_j2k do not recognize pipe input

What is the expected output? What do you see instead?
expected output is j2c image. Instead in case of "-" as input say unrecognized 
file, without -i option say must have input image in PNG,TIFF.....

What version of the product are you using? On what operating system?
version 2.0 windows 7 64 bit

Please provide any additional information below.
convert image.tiff -(somefilter) rgb:- |image_to_j2k -i - -o output.j2c 
this pipe do mot work

Original issue reported on code.google.com by rado.mar...@gmail.com on 8 Jun 2013 at 3:35

GoogleCodeExporter commented 9 years ago
You use version 2.0 of the library, but version 2.0 does
not contain 'image_to_j2k' but 'opj_compress'.

  opj_compress -i infile.EXT -o outfile.EXT
or
  image_to_j2k -i infile.EXT -o outfile.EXT

Both test the outfile extension: JP2, J2k, etc

and decide whether the outfile should be done.

Both test the infile extension: PNG, BMP, etc

and decide which conversion function should be called:
pngtoimage, bmptoimage, etc.

The pipe stream does not contain an extension that
can be tested.

One could perhaps add a special input file name, e.g.

  '-i pipe:PNG' or '-i pipe:png'

to call pngtoimage.

winfried

Original comment by szukw...@arcor.de on 13 Jul 2013 at 7:41

GoogleCodeExporter commented 9 years ago
cat file7.png  | bin/opj_compress -i pipe:png -o file7.j2k

[INFO] tile number 1 / 1
Generated outfile file7.j2k

---------------
CHANGES
---------------

convert.c:
===============

pngtoimage(const char *read_idf, opj_cparameters_t * params)
{
    int piped = 0;

    if(strcmp(read_idf, "pipe:png") == 0)
   {
    reader = stdin; piped = 1;
   }
    else
    if((reader = fopen(read_idf, "rb")) == NULL)
   {
    fprintf(stderr,"pngtoimage: can not open %s\n",read_idf);
    return NULL;
   }

}

opj_compress.c:
===============

static int get_file_format(char *filename)
{
    char *ext = strrchr(filename, '.');

    if (ext == NULL)
     ext = strrchr(filename, ':');

    if(ext == NULL) return -1;

    ++ext;

}

winfried

Original comment by szukw...@arcor.de on 13 Jul 2013 at 8:41

GoogleCodeExporter commented 9 years ago
In the above sketch add at the very end of pngtoimage():

    if(!piped) fclose(reader);

winfried

Original comment by szukw...@arcor.de on 14 Jul 2013 at 5:38

GoogleCodeExporter commented 9 years ago

Original comment by mathieu.malaterre on 24 Feb 2014 at 5:25

GoogleCodeExporter commented 9 years ago
Issue 379 has been merged into this issue.

Original comment by m.darb...@gmail.com on 23 Oct 2014 at 9:34

GoogleCodeExporter commented 9 years ago
Renamed to add opj_decompress & writing over stdout

Original comment by m.darb...@gmail.com on 23 Oct 2014 at 9:36

GoogleCodeExporter commented 9 years ago
The absence of file extension can easily be overcome by using magic numbers. 
They are much more reliable than file extensions anyways.

Original comment by njdo...@gmail.com on 23 Oct 2014 at 10:03