trying to extract formatted images from indesign into a separate folder - flash-cs5

I'm looking for a way to extract images from an ID file in a 'formatted' / cropped form.
i.e: a. I have placed numerous, hi-res (tiff, psd) images into an InDesign CS5 file
b. The image boxes that they have been placed into, are smaller than the actual image (pretty intense cropping occurred) c. I am trying to collect these images in their new stage (cropped to the image box) and export them as jpg at 72dpi.
Are there any plug-ins out there that would automatically collect "formatted" images from ID for me? Or is there some other way?

If you're familiar with Indesign Scripting, this can very easily be done via a script. I use Javascript but this can be done with VBSript or AppleScript as well. Here is a basic example of a script that will open a document, and export a rectangle (your image box) as a JPG. Basically, you can just loop through the pictures in your document and export each one to a location/filename you choose (see the myFile variable below). There are several "jpegExportPreferences" you can pick from to determine how your output JPG will be (i.e. DPI).
test();
function test(){
var myDoc = app.open('c:/user/desktop/testDocument.indd');
var myGroups = myDoc.groups;
//for each group...
for (var i = 0;i < myGroups.length; i++){
// for each rectangle in the group...
for(var r = 0; r< myGroups[i].rectangles.length; r++){
var myRect = myGroups[i].rectangles[r];
app.jpegExportPreferences.exportResolution = 300;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM;
//give it a unique name
var myFile = new File('c:/users/desktop/newJPG' + myRect.id + '.jpg');
myRect.exportFile(ExportFormat.JPG, myFile);
}
}
}
For a list of the other optional JPG Export preferences, see this link:
http://indesignscriptingreference.com/cs2/javascript-cs2/jpegexportpreference.htm
Hope this helps!

Related

Convert pptx to images using java

i try to write a java program, which converts the pptx to jpeg images. There are many options (e.g., aspose, groupdocs, cloudmersive). But they are limited (either generating images in the evaluation mode or limited by the number of API calls); i prefer an open source library and up till now, i have known 2 libreries which are Apache POI and Docx4j. By using the Apache POI, i was able to implement the conversion PPTX-JPEG; however, the generated images' quality is low even the rendering parameters were set.
// create an empty presentation
public static void Pptx_Img(String slidePath, String outputDir, String fileName) throws Exception {
// create an empty presentation
File file = new File(slidePath);
FileInputStream in = new FileInputStream(file);
XMLSlideShow ppt = new XMLSlideShow(in);
// get the dimension and size of the slide
Dimension pgsize = ppt.getPageSize();
List<XSLFSlide> slides = ppt.getSlides();
JPEGImageWriteParam jpegParams = new JPEGImageWriteParam(null);
jpegParams.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
jpegParams.setCompressionQuality(1f);
BufferedImage img = null;
outputDir = outputDir + "\\apache\\pptx\\" + fileName;
Apache.createDirIfNotExists(outputDir);
for (int i = 0; i < 10; i++) {
img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
graphics.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
graphics.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
graphics.setRenderingHint(Drawable.BUFFERED_IMAGE, new WeakReference<>(img));
// clear area
graphics.setPaint(Color.white);
graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
// draw the images
slides.get(i).draw(graphics);
FileOutputStream out = new FileOutputStream(outputDir + "\\slide_" + i + ".jpg");
/*
// specifies where the jpg image has to be written
final ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next();
writer.setOutput(ImageIO.createImageOutputStream(out));
// writes the file with given compression level
writer.write(null, new IIOImage(img, null, null), jpegParams);
*/
ImageIO.write(img, "jpeg", out);
ppt.write(out);
graphics.dispose();
out.close();
img.flush();
}
System.out.println("Images successfully created");
in.close();
ppt.close();
}
Comparison between the original slide and the generated images
I also came up with another indirect way, which converts pptx-pdf-jpeg (because i have the implementation for conversion pdf-jpeg and the conversion can actually maintain the image quality). But i couldnt find any open source libs which can do the conversion pptx-jpeg. For Apache POI, it can convert pptx-pdf but the mechanism is just similar to pptx-jpeg: writes the Graphic2D-instance to pdf instead of jpeg, which basically does not improve the rendering quality.
Added: Regarding to the comparison, the wrong rendering is also another issue !

How do I carry over identical texture mapping when exporting to DAE?

I am able to open a 3DS file in MeshLab and when I export to Collada DAE format the textures are visible but they are not being projected onto the mesh in the same way as the preview in MeshLab. For example, the front/back faces of a cube would have the proper texture (suppose it's a polka dot) but the top and bottom have a striped look. How can I apply a single texture and have it appear as intended on all faces, like the imported model before I convert it?
This problem is a result of the end software being used to view the DAE file. It's not a problem with MeshLab.
For example, if loading the file into Away3D be sure to handle the texture materials using the TextureMaterial class instead of the simpler SinglePassMaterialBase such as what you might find in their example code. Here is what I use now, and it displays texture properly:
var material:TextureMaterial = cast(asset, TextureMaterial);
material.ambientColor = 0xffffff;
material.lightPicker = _lightPicker;
material.shadowMethod = new FilteredShadowMapMethod(_light);
material.lightPicker = _lightPicker;
material.gloss = 30;
material.specular = 1;
material.ambient = 1;
material.repeat = true;

Easily convert between Fabric JS IText and Textbox?

Is there a way to easily convert a Fabric JS IText into a TextBox (new in 1.6.0) and vice versa, without having to laboriously read and set every single property of them, i.e. some quick way of mapping between them?
Thanks.
you can easily do
var text = oldItext.text;
var textobj = oldItext.toObject();
delete textobj.text;
delete textobj.type;
var clonedtextobj = JSON.parse(JSON.stringify(textobj));
var textbox = new fabric.Textbox(text, clonedtextobj);
a note about use of json:
normal toObject method in Fabricjs does not take care of deep cloning. so the new textbox you create would share the same style object with the old itext. That is not necessarly bad untill you create 2 copies from 1.
if you are not using styles, a faster way is:
var text = oldItext.text;
var textobj = oldItext.toObject();
delete textobj.type;
var textbox = new fabric.Textbox(text, textobj);

JavaFX Pagination - Update the content of current page

In my JavaFX application I use Pagination to show some pictures. Reading the pictures takes much time so I fill an ObservableList<Image> with placeholder images, which should be replaced by the originals when they are loaded.
Everything works fine, but the only thing is that the current page doesn't get updated when the image is loaded. I have to change the CurrentPageIndex and change back. Than the right picture is displayed.
For loading the images I've created a Task, so that I'm able to use the Application during the process.
So my Question is, how is it possible to update the content of the current page?
The PageFactory looks like that:
ImageView imageView = new ImageView();
Image img = images.get(index);
imageView.setImage(img);
imageView.setFitWidth(240);
imageView.setStyle("-fx-background-color: white");
imageView.setPreserveRatio(true);
imageView.setSmooth(true);
imageView.setCache(true);
imageView.setEffect(createShadow(Color.BLACK, false));
VBox pageBox = new VBox();
pageBox.setAlignment(Pos.CENTER);
pageBox.getChildren().add(imageView);
return pageBox;
Here I replace the images (first 2 lines are methods of a framework):
for (int i = 0; i < pageCount; i++) {
PagePainter pp = parser.getPagePainter(i);
BufferedImage buffImg = pp.getImage(200);
fxImages.set(i, SwingFXUtils.toFXImage(buffImg, null));
}

How to get a pdf embedded fonts using PDFBOX0.8.0

My code:
FileInputStream pdfFile = new FileInputStream("C:/work/pdf2tiff/test.PDF");
PDDocument pdDocument = PDDocument.load(pdfFile, true);
PDDocumentCatalog catalog = pdDocument.getDocumentCatalog();
List pages = catalog.getAllPages();
if (pages != null && pages.size() > 0) {
for (int i = 0; i < pages.size(); i++) {
PDPage page = (PDPage) pages.get(i);
Map fonts = page.getResources().getFonts();
System.out.println("fonts=" + fonts);
I got output:
fonts={F0=org.apache.pdfbox.pdmodel.font.PDType1Font#8aaed5,
F4=org.apache.pdfbox.pdmodel.font.PDType0Font#dc4414,
F2=org.apache.pdfbox.pdmodel.font.PDType0Font#f98ce0,
F6=org.apache.pdfbox.pdmodel.font.PDTrueTypeFont#18fcdce}
Why the fonts map's key is F0/F1/F2/F6? What these mean?
Should I iterate all pdf pages get all fonts?
Thanks for your answer.
It seems like the pdf you loaded has multiple fonts loaded. I couldn't figure out any way to retrieve fonts from a document (which I think should be available for us to retrieve since we load fonts to a particular document).
I'm guessing when you load a font into the document it uses "F0", "F1", etc as keys to map to PDFont type. When you print fonts object, it's printing the memory location of the object.
To get all the embedded fonts, you can create a new HashMap() object, then iterate over all the pages and add each font to your HashMap(). Then you can iterate over the keys, get the PDFont font object and, use font.getSubType() to get some sort of description of the font.
Hope this helps. Good luck!

Resources