Save for the web by calling Export possible c# (exportDocument)?

I try to call the c# Export function and I'm having a hard time to provide a valid file object.

I picked up the old COM FileSystemObject and tried (because who has the habit of working in VB6 and VBScript).

In c# I had not yet run. Any ideas?

I have a piece of code using ExecuteAction to run a number of difficult to understand lines of code, execution of save for Web, for an image.

I am now rewriting to call the method to export the document instead, because it would be so much easier to follow).

It's my current test code

// Using the export function (instead of hard-to-understand-output-script)
        private void SaveJpegForWebUsingExport(dynamic docRef, string filePath, int percentage)
        {

            // Begin with deleting the destination image if it already existed on disk.
            if (System.IO.File.Exists(filePath))
            {
                System.IO.File.Delete(filePath);
            }

            dynamic options = Activator.CreateInstance(Type.GetTypeFromProgID("Photoshop.ExportOptionsSaveForWeb"));
            options.quality = percentage;
            options.format = 6; // JPEG = 6 (enl Object Model Viewe i Extenscript Toolkit)  .Type.GetTypeFromProgID("SaveDocumentType.JPEG");   // Save Format for the file
            
              // Create an empty file, to be able to referr to it using filesystemobject (is this really needed?)
            var myFileEmpty = System.IO.File.Open(filePath,System.IO.FileMode.CreateNew);
            myFileEmpty.Close();

            var fs = new IWshRuntimeLibrary.FileSystemObject();
            var myFile = fs.GetFile(filePath);
          
           // ExportType.SAVEFORWEB = 2 (according to Object Model Viewe in Extenscript Toolkit)
            docRef.Export(myFile, 2, options);
            //docRef.Export(myFile.ParentFolder, 2, options);

        }

This is the error I get, so of course the file (I tested with folder as well) object is not recognized as a valid type in Photoshop:

Test1.EPS processing error: System.Runtime.InteropServices.COMException (0 x 80040

4DA): non-compliant - argument argument 1

File/folder provided

at System.Dynamic.ComRuntimeHelpers.CheckThrowException (Int32 hresult, ExcepI

NFO & excepInfo, argErr UInt32, String message)

to CallSite.Target (closure, CallSite, ComObject, folder, Int32, Object)

Thank you

Andreas

This seems to work...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ps = Photoshop;
namespace ConsoleApplication1
{
    class Program
    {
        ps.Application app = new ps.ApplicationClass();
        static void Main(string[] args)
        {
            Program mp = new Program();
            string file = @"C:\Vids\frog.jpg";
            mp.SaveJpegForWebUsingExport(file, 80);
        }
        private void SaveJpegForWebUsingExport(string filePath, int percentage)
        {
            // Begin with deleting the destination image if it already existed on disk.
            if (System.IO.File.Exists(filePath))
            {
                System.IO.File.Delete(filePath);
            }
            dynamic options = Activator.CreateInstance(Type.GetTypeFromProgID("Photoshop.ExportOptionsSaveForWeb"));
            options.quality = percentage;
            options.format = 6; // JPEG = 6 (enl Object Model Viewe i Extenscript Toolkit)  .Type.GetTypeFromProgID("SaveDocumentType.JPEG");   // Save Format for the file
            // ExportType.SAVEFORWEB = 2 (according to Object Model Viewe in Extenscript Toolkit)
            app.ActiveDocument.Export(filePath, 2, options);
        }
    }
}

Tags: Photoshop

Similar Questions

  • Save for the Web Glitch? Illustrator 2015.3 CC

    I just updated my CC Illustrator to the latest version (2015.3), and I notice that when you use 'Save for Web' it automatically returns to the default value, which is GIF... I tried to create presets and repeat the process several times hoping that it will retain the previous setting I used that ideally is JPEG, but in vain.  The previous version of Illustrator remember my previous settings during export, but now I have to manually switch each setting time and time again.  I use 'Save for Web' a lot, so it becomes a boring potential nightmare for me.

    Any ideas?

    Data sheet:

    Illustrator 2015.3 CC

    OS X Yosmite 10.10.5

    Processor: Intel Core i5 at 2.9 GHz

    Memory: 8 GB 1600 MHz DDR3

    Graphics card: NVIDIA GeForce GT 750 M 1024Mo

    Hello

    We are preparing a fix for this problem. We invite you to participate in our pre-release program and enter the building from the beginning if this can help. We have already published a version that resolves this problem.

    Under the pre-release program you will have access to our latest versions and get an opportunity to share your comments and suggestions with the teams directly product Illustrator and engineering. If you are interested in joining this program, click on http://adobe.ly/1Q3rCPI . A few prerequisites to participate in the program: a subscription is valid. Latest version of Illustrator installed on your machine.

    Thank you

    Ashutosh chikh

    The quality of the SR - Illustrator Engineering Manager

  • Save for the web just for display or for sending, too?

    I need to send files with layers, so I won't use it save for web or I'm going to lose, I thought a general save as. I heard that save for web translates your web language file, now these files will be worked again and, possibly, validated, but not by me right now. I send you just them.

    Is to save for web recommended any time you send files to an email, or just for display?

    Sorry I have to go now, but I'll be happy to read you tomorrow.

    Marian Driscoll wrote:

    ... There are options to include [metadata in the save for Web dialogue]...

  • Save for the web went... help please

    my web save has been replaced by Save to model

    I can't find a way to fix it. Help!

    File > export > save for web ?

  • Save for the Web and the Options in the Section

    Why when I "save for web" in my .psd document, this action create a document with defined sections and a folder with images related to the sections?

    Havy you tried (cited in the documentation)

    3. If you want to delete all user slices and layer-based slices, choose View > clear slices.

    ?

  • Logo is absent from the elements when I save for the web

    I was given a logo to work with a project, but every time I try to save it as a GIF, jpeg, or in a different image format, the text in the logo is missing.

    Here is a screenshot of what it is supposed to look like:

    Liz1.jpg

    Here is a screenshot of what it looks like when you save for web:

    Liz2.jpg

    I adjusted the color the butterfly and the text to the clear green color, you see, but the text is missing and some original colors appear on the save for web viewing.

    I tried without success to the following:

    • Copy / paste the logo
    • Changing colors
    • Separate logo
    • Expand the logo
    • Addition of stroke
    • Live Paint

    Save as a PDF file works, but when I tried to print flyers with the image to the Kinkos, I met the same problem with the text disappearing.  Does anyone know how to fix this?  I know that I could just put it in Photoshop to get the final product I want, but I'm going to use this logo in the future and don't want to experience the hassle again.

    This is Illustrator CS5, and I work on a PC.


    Thank you.

    Looks like you got the white fill set to overprint.

    Select the text that is disppearing, and go to the attributes Panel and see if overprinting is enabled.

  • Save for the Web default file type in PSE 8 on Windows 7

    I just installed PSE 8 on a new Windows 7 system. On my previous Windows XP running PSE 6 system, the Save for Web file by default JPEG medium, which is what I wanted to type. On this installation, it is by default every time to GIF format; I have change and save the file as a JPEG, and the following default is again in the GIF format. Closure of PSE, restart Windows, nothing changes that. I would like to make it the default JPEG medium; is there a way?

    On a MAC, it doesn't stick on the last option you have saved for example Jpeg, if it was a Jpeg image.

    For windows, it seems to work:

    Search for the file using Explorer PhotoshopElementsEditor.exe (in the folder C:\Program Adobe Photoshop Elements 8.0) right-click on this file and choose Run as administrator.

    Go back to the editor, open an image, select Save for Web and choose jpeg; then save this file. The next time that you run the editor and use web order registration, type jpeg should hopefully stick as the default.

  • best practices for the web service call

    Can I add a web service by using the standard data connection Wizard - works fine. I can also do it in Javascript which give me a little more flexibility. Is there a guideline or wisdom for which is better?

    Everything depends on your condition...

    For example, if you know your address Web service at the time of the design itself, then it would be better to put in the tab of data connection.

    But if your webservice address changes at runtime based on the environment in that your application is deployed, then you can use the java script code to change the webservice dynamically address.

    Thank you

    Srini

  • Conversion error in CFML arguments to the Java classes for the web service call.

    Hi all.

    I'm working on writing a small application that uses a web service that is provided by our IVR (Angel.com). I am able to connect, however, when I try to do something with complex objects, I get the error indicated in the title.

    He seems to have a problem with the table because when I remove it, or it becomes a simple string, I get errors on the function could not be found. I'm relatively new to web services, and especially dealing with complex data types, so any help would be appreciated.

    You can see my test page to

    http://webservices.fpitesters.com/AngelCalls.cfm

    I use the language WSDL can be found at

    http://www.Angel.com/outbound/WSDL/OutboundCallService.WSDL

    Some examples of code that does what I want to do in Java / Apache Axis

    http://www.Socialtext.NET/ivrwiki/index.cgi?java_sample_code

    Here is a description of the function that I have problems with

    http://www.Socialtext.NET/ivrwiki/index.cgi?placecall

    And my code is attached.

         <cfset email = "xxxxxxxxxxxxxxxxxx">
         <cfset pin = "xxxxxxxxxxxx">
    
    
         
         <cfinvoke webservice="http://www.angel.com/outbound/wsdl/OutboundCallService.wsdl" method="login" returnvariable="login">
              <cfinvokeargument name="email" value="#email#"/>
              <cfinvokeargument name="pin" value="#pin#"/>
         </cfinvoke>
    
         <cfdump var="#login#">
         
         <cfset Token = login.getToken()>
         
         <cfdump var="#token#">
         
         <cfset CallItem.maxWaitTime = 100>
         <cfset CallItem.phoneNumbers[1] = "7632344306">
         <cfset CallItem.siteNumber = 100041>
         
         <cfinvoke webservice="http://www.angel.com/outbound/wsdl/OutboundCallService.wsdl" method="placeCall" returnvariable="call">
              <cfinvokeargument name="Token" value="#Token#"/>
              <cfinvokeargument name="CallItem" value="#CallItem#"/>
         </cfinvoke>
         
         <cfdump var="#call#">
    

    If you are not initializing phoneNumbers tabular before adjustment

    
    

    It will be passed as a structure with a key of 1.  This could cause your conversion of argument error.

    So:

    
    

    Will result in

    struct
    MAXWAITTIME 100
    PHONENUMBERS
    struct
    1 7632344306
    SITENUMBER 100041
      
    

    Will result in

    struct
    MAXWAITTIME 100
    PHONENUMBERS
    Table
    1 7632344306
    SITENUMBER 100041

    -Jason Morgan

  • size of files when saving for the web

    'Save for web' sometimes export icon to very small size with size huge file (500Ko), when I take the same image and re - record using "Save for web", I get the small file (1 or 2 KB)

    Why does this happen?

    This happens because Photoshop is save the metadata in your PSD and JPG files. You can see that from Photoshop in file Info under the file menu, and then on the tab of raw data you will be able to see usually several lines of metadata information, sometimes thousands, and if you did a lot of manipulations on the file that can add literally MBs to the size of the file. Save for the Web and export as you can delete metadata. Personally, I find it a nuisance more than a useful feature tends to remove metadata from Lightroom, there is a plugin that allows you to select what you want to keep and what to throw away.

    Hope that helps

    Terri

  • Prep file InDesign for the web.

    PSCS5, Mac OS 10.6.4

    I need to prepare a book cover created in InDesign display with online sellers (Angus & Roberton, Austraila, and Amazon for beginners). My first attempt and prepare the InD file for the web has failed. No file is available from each provider. Can you help me?

    The InD file is 8 "x 8", contains 2 images, 2 vectors of I and PS text. " PS files are set at 350 dpi (by record the print service bureau). The book is intended for the wet press 4 colours. The first set of wet proofs are superb, so I know I'm on the right track with color, related, etc. images management.

    My first approach when I tried it prepare for the web was to export the InD file in a JPEG file, open it in PS and save it as a .psd file before making any changes. After you convert the color in RGB, I resize to 3 "x 3" at 72 dpi, then saved as a JPEG file with a new name. "  I think that the resizing and resolutoion is where I was wrong. But I am at a loss for the right way forward and what parameters to use for the image size and resolution.

    What is the procedure I should I have followed to prepare the cover over a picture for the web? Here is the image exported in JPEG format at 150 dpi.

    Thanks in advance.

    Toni

    cover_for_web.jpg

    Toni...

    I'm doing print and web and often take a page ID to an image.

    What I do...

    1. Export Indesign to PDF. (Use any standard PDF job option you have, same PDFX1a)
    2. Drag the PDF Photoshop > open 300 PPI and no matter what the dimensions are already present.
    3. If necessary, crop and flatten the image in Photoshop. (PDFx1a will be cropped and flattening will offset any transparency in the PDF file.)
    4. In Photoshop > file > save for Web > dimensions of the input image I need in the box dialog SFW
    5. Click Save.

    What's been sent by others is correct. There is no PPP/DPI for the web. The only thing that matters is the width and height. If you want you can test to show you. Create 2 images - one to 100 x 100 pixels and 300ppi and the other to 100 x 100 pixels and 72 dpi. Save the two images for the web, and then open the pictures stored in a browser... they are the same size and look identical.

    Export to PDF from ID, you get a crisp, clean the PDF.

    By dragging the PDF to PS, you get a purified PS image. If you export a jpg of ID and then save a jpg of PS that you create artifacts due to the re-registration of a compressed format (jpg).

    Using save for Web to create the final image all the superfluous image data are robbed and you get a basic, clean and crisp image to the size entry in the SFW.

    There are other roads, you can take, but for me this five-step process gives the best results in all cases.

  • Best app for the batch processing of photos for the web?

    I would like to know what is the best application for batch processing photos for the web quickly and easily. I'm a web editor and often need to resize, compress, or crop several photos and would like a quick way to configure the basic parameters and processes for example 20 pictures at once. Basically, I'm looking for something with the ability to FastStone Photo Resizer (I'm on a Mac and cannot use FastStone). I remember an once suggested graphic designer LightRoom - would that be a good idea or Adobe has something else? Or maybe not Adobe at all?

    PhotoShop seems heavy for this purpose: it is ideal to make the photo woth that much at the time, but less large to do less with many pictures at once. I know that I can implement some sort of macro-thingie, but I would like to be able to quickly change settings such as the percentage of compression or the width in pixels.

    I don't need a lot of editing tools, mostly just work in pixels, resizing, compression or cropping and save for the web in .jpg and .png - and Mac.

    I hope someone here can guide me in the right direction.

    Hi eval

    I think the best thing for you is Adobe photoshop elements, cover in simple not expensive and all what you want

    Photo Editor software & tools | Adobe Photoshop Elements 14

    concerning

  • How can I change the action save to the web to do not overwrite an existing file?

    I created an action script where I change the color of objects in a picture and then the measures were automatically save for web as a PNG-24 image. My problem is that save for the web has continuously overwrites the existing file to this location. Is in any way to prevent that from happening?

    The downloadable Image Processor Pro plugin script from Russell Browns website. Once installed, it will be found under the file menu > Automate > Image Processor Pro... will save the PNG files and many other file types the standard does not support the Image Processor. You can also save as many times as you need.

  • What is the best way to keep the high resolution when recording "for the web".

    the files that I save to the web so I can get them in jpg (or gif) are coming very pixelated.  That's when I print the image.

    What is the best way to save for the web, an image and keep the good resolution.

    using a business card template.  template Avery will allow me to attach images I want to project.  to do this...  I 'get file computer' and it deletes the image in but real little... then you are supposed to expand on your work as you want.  Well, when I enlarge this image file, it gets pixelated bad.  I think it's the way that I am saving it.  I do not adjust anything when I save.  Maybe I should.  This is where I need advice.

    That's what avery model notes on the images, I am allowed to use - when downloading the image, the maximum allowed size is 4 MB.  You can download the JPG and PNG RGB or CMYK images.  so when you recommend things, can you please take this into account

    Thanks for oyur times.

    Aida,.

    When you register with the default template using save for web, it's usually a setting very low.

    While in the registration window, you can set the size in pixels of the image you want with the quality and the resolution too.

    Refer to video tv.adobe.com save for web or Adobe Help file for detailed instructions.

    Florian

  • save multiple files for the web in JPEG max at a resolution of 800%

    I had more than 200 created illustrator files. They all have the same dimensions. I wanted an adobe illustrator script that saves all files for the web in jpeg.

    Export options must be max.resolution of all files should be increased to 800%.

    I think it's the reasoning

    Open a folder with all the files

    loop through each file

    Save for web each in jpeg format to the quality of resolution and up to 800%

    the names of all jpeg files should be the same from these illustrator files (if possible)

    I will be very thankful to you if you could help me

    Best regards,

    Hassan Ali

    As far as I understand your request it is also possible with a simple action in batch mode.

Maybe you are looking for

  • Tecra A2: How to install the OS whithout to remove partition D

    I have original windows xp installed on my Tecra A2, now I want to reinstall windows using the recovery cd but I don't want my data to be deleted from the D drive, would it be possible to install the C disk recovery cd and do not touch the drive D...

  • My Ipod shuffle doesn't work anymore

    When it is taken there is a green light, but my computer does not recognize it. Then when I turn it on I also have a green light but no music. When I press play there is also the green light but no music. Other buttons do not work.

  • 3270nr HP Envy, random BSOD

    I bought it a few months ago the beginning of the year, it worked great, was able to leave it on for a few days with no problems at all, but this week he started getting random BSOD, I did a test of stress with the CPU, was 100% usage for 20 minutes

  • HP Officejet 4630: HP Officejet 4630 than all the shortcuts to print are locked

    The printer is new and is connected via the USB port on the computer that is running a new copy of Windows 10 x 64 ('fees': I've upgraded to Windows 10 and reset the computer). The driver is from the OJ4630_Basicx64_198.exe file (so just basic pilot)

  • Code error 800b0100 when installing update Vista KB979559

    I am running Vista SP2, when you try to update KB979559 I get error 800b0100 code. What should I do? I tried disabling my firewall. still the same error.