Package com.lightcrafts.image.export

Examples of com.lightcrafts.image.export.ImageFileExportOptions


     */
    public ImageFileExportOptions createExportOptions( ImageInfo imageInfo,
                                                       Dimension saveSize )
        throws IOException, LightCraftsException
    {
        final ImageFileExportOptions options;
        final ImageType t = imageInfo.getImageType();
        final String ext;
        if ( t instanceof JPEGImageType ) {
            options = SidecarJPEGImageType.INSTANCE.newExportOptions();
            ext = t.getExtensions()[0];
        } else {                        // TIFF or raw
            options = SidecarTIFFImageType.INSTANCE.newExportOptions();
            ext = TIFFImageType.INSTANCE.getExtensions()[0];
        }
        initOptions( options, imageInfo, saveSize );

        //
        // Since iPhoto gives us the original file (which may be raw), we need
        // to replace the filename extension since we don't save as raw.
        //
        // For non-raw files, this normalizes the filename extension, e.g.,
        // "jpeg" becomes "jpg" and "tiff" becomes "tif".
        //
        String saveFileName =
            FileUtil.replaceExtensionOf( imageInfo.getFile(), ext );

        //
        // Insert (if necessary) a suffix to distinguish sidecar JPEG/TIFF
        // files from ordinary JPEG/TIFF files.
        //
        saveFileName = FileUtil.insertSuffix( saveFileName, "_lzn" );

        //
        // We have to save the file to /tmp rather than in the same folder as
        // the original because iPhoto refuses to import any file that's
        // already within its directory structure.
        //
        File saveFile = new File( saveFileName );
        saveFile = new File( FileUtil.getTempDir(), saveFile.getName() );
        saveFile = FileUtil.getNoncollidingFileFor( saveFile );
        options.setExportFile( saveFile );

        //
        // Because iPhoto copies the file on import (by default), we can mark
        // the saved file to be deleted on exit.
        //
View Full Code Here


            else {
                dir = LastSaveOptions.getFile().getParentFile();
            }
            options = SaveOptions.getDefaultSaveOptions();

            ImageFileExportOptions export =
                (ImageFileExportOptions) SaveOptions.getExportOptions(options);
            ImageType type = export.getImageType();

            File file = new File(dir, meta.getFile().getName());
            String name = ExportNameUtility.getBaseName(file);
            name = name + "_lzn." + type.getExtensions()[0];
            file = new File(name);
View Full Code Here

    }

    // Export an image rendering to a file
    public void write( ProgressThread thread,
                       ImageExportOptions exportOptions ) throws IOException {
        final ImageFileExportOptions fileOptions =
            (ImageFileExportOptions)exportOptions;
        final ImageType exportType = exportOptions.getImageType();
        final int exportWidth = fileOptions.resizeWidth.getValue();
        final int exportHeight = fileOptions.resizeHeight.getValue();
View Full Code Here

    // Conduct the export and template processes, in the background under the dialog.
    static void processTemplate(
        File[] files, XmlDocument template, BatchConfig conf
    ) {
        ImageFileExportOptions export = conf.export;
        boolean ignoreResize =
            export.resizeWidth.getValue() == 0 &&
                export.resizeHeight.getValue() == 0;

        // Remember the requested output width and height, because they may get
        // mutated each time a file is processed.  See these methods:
        //     createTemplateSaveOptions()
        //     conformExportOptions()
        //     Engine.write()
        int exportWidth = export.resizeWidth.getValue();
        int exportHeight = export.resizeHeight.getValue();

        for (int n=0; n<files.length; n++) {
            if (Canceled)
                break;

            if (Interrupted) {
                synchronized(Thread) {
                    Thread.notifyAll();
                    return;
                }
            }

            try {
                File file = files[n];

                Image.setCachedFile(file);

                logStart(file);
                Document doc = Application.createDocumentHeadless(file);
                File outFile;
                String outName;

                // Enforce the original requested output dimensions, since
                // the ImageExportOptions may have been mutated on a previous
                // iteration.
                export.resizeWidth.setValue(exportWidth);
                export.resizeHeight.setValue(exportHeight);

                if (template != null) {
                    XmlNode root = template.getRoot();

                    doc.applyTemplate(root);

                    SaveOptions save = doc.getSaveOptions();
                    if (save == null) {
                        save = createTemplateSaveOptions(doc, export, ignoreResize);
                    }
                    doc.setSaveOptions(save);

                    ComboFrame frame = (ComboFrame) Dialog.getOwner();
                    DocumentWriter.save(doc, frame, false, Progress);
                    outFile = save.getFile();
                    outName = outFile.getName();
                    DocumentDatabase.addDocumentFile(outFile);
                } else {
                    conformExportOptions(doc, conf, ignoreResize);

                    Engine engine = doc.getEngine();
                    DocumentWriter.export(engine, export, Progress);
                    outFile = export.getExportFile();
                    outName = outFile.getName();
                }

                doc.dispose();
View Full Code Here

        // Mutate the default file into a conformant name:
        String outLabel = conf.name;
        String outName = ExportNameUtility.trimFileExtension(
            outFile.getName()
        );
        ImageFileExportOptions export = conf.export;

        String outSuffix = export.getImageType().getExtensions()[0];
        if (outLabel.length() > 0) {
            outFile = new File(
                directory,
                outName + outLabel + "." + outSuffix
            );
        }
        else {
            outFile = new File(
                directory, outName + "." + outSuffix
            );
        }
        outFile = ExportNameUtility.ensureNotExists(outFile);
        export.setExportFile(outFile);

        if (ignoreResize) {
            Engine engine = doc.getEngine();
            Dimension size = engine.getNaturalSize();
            export.resizeWidth.setValue(size.width);
View Full Code Here

    public ImageFileExportOptions createExportOptions( ImageInfo imageInfo,
                                                       Dimension saveSize )
        throws IOException, LightCraftsException
    {
        final ImageType t = imageInfo.getImageType();
        final ImageFileExportOptions options;
        if ( t instanceof JPEGImageType ) {
            //
            // The only case when Lightroom gives us a JPEG is when (a) the
            // original is a JPEG and (b) the user selects "Edit a Copy".
            //
View Full Code Here

    // Prevent update loops:
    private boolean isXUpdating;
    private boolean isYUpdating;

    ExportSizeFields(ImageExportOptions options) {
        final ImageFileExportOptions fileOptions =
            (ImageFileExportOptions)options;

        IntegerExportOption widthOption = fileOptions.resizeWidth;
        IntegerExportOption heightOption = fileOptions.resizeHeight;
View Full Code Here

                }
            }
        }
        // The default default:
        SaveOptions options = createSidecarJpeg();
        ImageFileExportOptions export =
            (ImageFileExportOptions) getExportOptions(options);
        // These default default sizes must match up with one of the multiple
        // choice options in ExportControls.
        export.resizeWidth.setValue(ExportControls.defaultSaveSize);
        export.resizeHeight.setValue(ExportControls.defaultSaveSize);
View Full Code Here

TOP

Related Classes of com.lightcrafts.image.export.ImageFileExportOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.