Skip to main content

Dialogic URA does not understand format of generated TIFF !!!

10 replies [Last post]
lcfonseca
Offline
Joined: 2007-04-06
Points: 0

I transformed a PDF (read by JPedal version 3.10b10STD) to TIFF. When sending this TIFF to Dialogic URA , it does not understand the format. Somebody can help me?

Att.
Luiz Carlos Fonseca
http://www.fonsecanet.com.br

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
lcfonseca
Offline
Joined: 2007-04-06
Points: 0

new TIFF generated (with JAI):

Magic: 0x4949
Version: 0x2a
Directory 0: offset 8 (0x8) next 66330 (0x1031a)
SubFileType (254) LONG (4) 1<2>
ImageWidth (256) LONG (4) 1<1728>
ImageLength (257) LONG (4) 1<2200>
BitsPerSample (258) SHORT (3) 1<1>
Compression (259) SHORT (3) 1<3>
Photometric (262) SHORT (3) 1<1>
FillOrder (266) SHORT (3) 1<2>
StripOffsets (273) LONG (4) 1<292>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<1>
RowsPerStrip (278) LONG (4) 1<2200>
StripByteCounts (279) LONG (4) 1<66038>
XResolution (282) RATIONAL (5) 1<204>
YResolution (283) RATIONAL (5) 1<196>
Group3Options (292) LONG (4) 1<4>
ResolutionUnit (296) SHORT (3) 1<2>
PageNumber (297) SHORT (3) 2<2 0>
Software (305) ASCII (2) 22
BadFaxLines (326) LONG (4) 1<0>
CleanFaxData (327) SHORT (3) 1<0>

Directory 1: offset 66330 (0x1031a) next 0 (0)
SubFileType (254) LONG (4) 1<2>
ImageWidth (256) LONG (4) 1<1728>
ImageLength (257) LONG (4) 1<2200>
BitsPerSample (258) SHORT (3) 1<1>
Compression (259) SHORT (3) 1<3>
Photometric (262) SHORT (3) 1<1>
FillOrder (266) SHORT (3) 1<2>
StripOffsets (273) LONG (4) 1<66614>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<1>
RowsPerStrip (278) LONG (4) 1<2200>
StripByteCounts (279) LONG (4) 1<39878>
XResolution (282) RATIONAL (5) 1<204>
YResolution (283) RATIONAL (5) 1<196>
Group3Options (292) LONG (4) 1<4>
ResolutionUnit (296) SHORT (3) 1<2>
PageNumber (297) SHORT (3) 2<2 1>
Software (305) ASCII (2) 22
BadFaxLines (326) LONG (4) 1<0>
CleanFaxData (327) SHORT (3) 1<0>

lcfonseca
Offline
Joined: 2007-04-06
Points: 0

valid TIFF (with black ice fax)

Magic: 0x4949
Version: 0x2a
Directory 0: offset 52034 (0xcb42) next 84918 (0x14bb6)
ImageWidth (256) LONG (4) 1<1728>
ImageLength (257) LONG (4) 1<2200>
BitsPerSample (258) SHORT (3) 1<1>
Compression (259) SHORT (3) 1<3>
Photometric (262) SHORT (3) 1<0>
FillOrder (266) SHORT (3) 1<2>
StripOffsets (273) LONG (4) 1<8>
SamplesPerPixel (277) SHORT (3) 1<1>
RowsPerStrip (278) SHORT (3) 1<2200>
StripByteCounts (279) LONG (4) 1<52009>
XResolution (282) RATIONAL (5) 1<204>
YResolution (283) RATIONAL (5) 1<196>
Group3Options (292) LONG (4) 1<4>
ResolutionUnit (296) SHORT (3) 1<2>
PageNumber (297) SHORT (3) 2<2 0>

Directory 1: offset 84918 (0x14bb6) next 0 (0)
ImageWidth (256) LONG (4) 1<1728>
ImageLength (257) LONG (4) 1<2200>
BitsPerSample (258) SHORT (3) 1<1>
Compression (259) SHORT (3) 1<3>
Photometric (262) SHORT (3) 1<0>
FillOrder (266) SHORT (3) 1<2>
StripOffsets (273) LONG (4) 1<52220>
SamplesPerPixel (277) SHORT (3) 1<1>
RowsPerStrip (278) SHORT (3) 1<2200>
StripByteCounts (279) LONG (4) 1<32682>
XResolution (282) RATIONAL (5) 1<204>
YResolution (283) RATIONAL (5) 1<196>
Group3Options (292) LONG (4) 1<4>
ResolutionUnit (296) SHORT (3) 1<2>
PageNumber (297) SHORT (3) 2<2 1>

lcfonseca
Offline
Joined: 2007-04-06
Points: 0

//constants

private static final int DEFAULT_HEIGHT = 2200;
private static final int DEFAULT_WIDTH = 1728;
private static int totalPageCount = 0;
private static int currentPageJobInProgress = 0;
private static File fileSource;
private static File fileResult;

lcfonseca
Offline
Joined: 2007-04-06
Points: 0

} else {
paramPagesTags = new TIFFEncodeParam();
setParam(paramPagesTags);
setExtraParam(paramPagesTags, pageCount, totalPageCount);
RenderedImage renderedImage;
renderedImage = scaleToPix(tmp, 1728, 2200);
objPagesTags[pageCount][0] = renderedImage;
objPagesTags[pageCount][1] = paramPagesTags;
images.add(objPagesTags[pageCount]);
}
pageCount++;
}
}

lcfonseca
Offline
Joined: 2007-04-06
Points: 0

[b]/**
* ITERACAO
*/[/b]

for (int i = 0; i < fileNames.length; i++) {
stream = new FileSeekableStream(fileNames);
TIFFDecodeParam paramd = new TIFFDecodeParam();
ImageDecoder decoder = ImageCodec.createImageDecoder("TIFF", stream, paramd);
for (int j = 0; j < decoder.getNumPages(); j++) {
currentPageJobInProgress = pageCount;
RenderedImage tmp = decoder.decodeAsRenderedImage(j);
if ((j == 0) && (i == 0)) {
first = scaleToPix(tmp, 1728, 2200);

lcfonseca
Offline
Joined: 2007-04-06
Points: 0

public static boolean covertTiff(PdfDecoder pdfFile, File resultFile){
boolean result = true; int pages = pdfFile.getPageCount(); totalPageCount = pages; Object[][] objPagesTags = new Object[totalPageCount + 1][2];
Vector images = new Vector(); TIFFEncodeParam paramPagesTags; RenderedImage first = null; ParameterBlock pb = null; int pageCount = 0;
try {

[b]/**
* ITERACAO
*/[/b]

TIFFEncodeParam param = new TIFFEncodeParam(); setParam(param); setExtraParam(param, 0, totalPageCount); param.setExtraImages(images.iterator());
resultFile.getParentFile().mkdirs(); pb = new ParameterBlock(); pb.addSource(first); pb.add(resultFile.toString());
pb.add("TIFF"); pb.add(param); JAI.create("filestore", pb); System.gc();
} catch (Exception e) {
LOGGER.error(e);
}
pb = null; fileSource = null; fileResult = null; return result;
}

Jeff Kesselman

jai-interest@javadesktop.org wrote:

(What looks like his entire bloody source code)

Would you please mind not spamming the whole list with your entire code
base?

Thank you.

JK

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

lcfonseca
Offline
Joined: 2007-04-06
Points: 0

private static void setParam(TIFFEncodeParam param) {
param.setCompression(TIFFEncodeParam.COMPRESSION_GROUP3_2D); //259
param.setWriteTiled(false);
param.setTileSize(-1, DEFAULT_HEIGHT);
param.setLittleEndian(true);
param.setReverseFillOrder(true);
param.setT4Encode2D(false); //292
param.setT4PadEOLs(true);
}

lcfonseca
Offline
Joined: 2007-04-06
Points: 0

private static void setExtraParam(TIFFEncodeParam param, int PageNb, int TotalPageNb) {
String SoftwareVersion[] = new String[1];
SoftwareVersion[0] = "TIFF For Dialogic 1.0";
TIFFField[] dialogicTags;
dialogicTags = new TIFFField[11];
dialogicTags[0] = new TIFFField(254, TIFFField.TIFF_LONG, 1, (Object) new long[] { (long) 2 });
dialogicTags[1] = new TIFFField(258, TIFFField.TIFF_SHORT, 1, (Object) new char[] { 1 });
dialogicTags[2] = new TIFFField(262, TIFFField.TIFF_SHORT, 1, (Object) new char[] { 0 });
dialogicTags[3] = new TIFFField(274, TIFFField.TIFF_SHORT, 1, (Object) new char[] { 1 });
dialogicTags[4] = new TIFFField(282, TIFFField.TIFF_RATIONAL, 1, (Object) new long[][] { { (long) 204, (long) 1 }, { (long) 0, (long) 0 } });
dialogicTags[5] = new TIFFField(283, TIFFField.TIFF_RATIONAL, 1, (Object) new long[][] { { (long) 196, (long) 1 }, { (long) 0, (long) 0 } });
dialogicTags[6] = new TIFFField(296, TIFFField.TIFF_SHORT, 1, (Object) new char[] { 2 });
dialogicTags[7] = new TIFFField(297, TIFFField.TIFF_SHORT, 2, (Object) new char[] { (char) PageNb, (char) TotalPageNb });
dialogicTags[8] = new TIFFField(305, TIFFField.TIFF_ASCII, SoftwareVersion.length, (Object) SoftwareVersion);
dialogicTags[9] = new TIFFField(326, TIFFField.TIFF_LONG, 1, (Object) new long[] { (long) 0 });
dialogicTags[10] = new TIFFField(327, TIFFField.TIFF_SHORT, 1, (Object) new char[] { 0 });
param.setExtraFields(dialogicTags);
}

lcfonseca
Offline
Joined: 2007-04-06
Points: 0

public static RenderedImage scaleToPix(RenderedImage source, double pixX, double pixY) {
if (source == null) {
return null;
}
int ww = source.getWidth();
int hh = source.getHeight();
float fattX = (float) (pixX / ww);
float fattY = (float) (pixY / hh);
ParameterBlock parSC = new ParameterBlock();
parSC.addSource(source);
parSC.add(fattX);
parSC.add(fattY);
parSC.add(0.0f);
parSC.add(0.0f);
try {
source = JAI.create("scale", parSC, null);
return source;
} catch (Exception e) {
LOGGER.error(e);
return null;
}
}