How to convert the image to CMYK (from any format)?

It seems that it should be simple enough.

I tried to reverse engineer a function of her "warn if RGB.jsx" found: Photoshop CC 2015 / settings presets/Scripts/Warn if / applications/Adobe RGB.jsx

in this file, open the picture in Photoshop is taken and converted to RGB.

Well that's exactly what I want to do, except the other way around.

How can I write code that would take my 'current image' and change it to CMYK, as if I had to go in photoshop (GUI) Edit > convert to profile... > and select CMYK ball under "Destination space".

I need this in a function for another script I have.

I'm going beyond what I (with my poor attempt of reverse engineering of function "Warn if RGB.jsx" in place.

Thank you. I really could use the help, and I think it should be pretty simple.

try {
  var data = GetDataFromDocument( activeDocument );
  if ('eps' == data.extension.toLowerCase()) {
  //convert to cmyk
  Switch();
  }
  else{
  //run code to square up images
  toSquare();
  }
}
catch( e ) {
  alert(e);
}






//FUNCTIONS
///////////////////////////////////////////////
///////////////////////////////////////////////


function toSquare(){
  var savedRuler= app.preferences.rulerUnits;
  app.preferences.rulerUnits = Units.PIXELS;
  var w = app.activeDocument.width;
  var h = app.activeDocument.height;
  if(w>h) app.activeDocument.resizeCanvas (w, w, AnchorPosition.MIDDLECENTER);
  if(w<h) app.activeDocument.resizeCanvas (h, h, AnchorPosition.MIDDLECENTER);
  //if w==h already square
  app.preferences.rulerUnits = savedRuler;
}


///////////////////////////////////////////////


function GetDataFromDocument( inDocument ) {
  var data = new Object();
  var fullPathStr = inDocument.fullName.toString();
  var lastDot = fullPathStr.lastIndexOf( "." );
  var fileNameNoPath = fullPathStr.substr( 0, lastDot );
  data.extension = fullPathStr.substr( lastDot + 1, fullPathStr.length );
  var lastSlash = fullPathStr.lastIndexOf( "/" );
  data.fileName = fileNameNoPath.substr( lastSlash + 1, fileNameNoPath.length );
  data.folder = fileNameNoPath.substr( 0, lastSlash );
  data.fileType = inDocument.fullName.type;
  return data;
}


///////////////////////////////////////////////


function Switch() {
  var eventModeChange = stringIDToTypeID( "8cba8cd6-cb66-11d1-bc43-0060b0a13dc4" );
  var descSource = new ActionDescriptor();
  var keySourceMode = charIDToTypeID( "SrcM" );
  var list = new ActionList();
  var keyCondition = charIDToTypeID( "Cndn" );
  var keyBitmap = charIDToTypeID( "UBtm" );
  var keyGrayscale = charIDToTypeID( "UGry" );
  var keyDuotone = charIDToTypeID( "UDtn" );
  var keyIndex = charIDToTypeID( "UInd" );
  var keyRGB = charIDToTypeID( "URGB" );
  var keyCMYK = charIDToTypeID( "UCMY" );
  var keyLab = charIDToTypeID( "ULab" );
  var keyMultichannel = charIDToTypeID( "UMlt" );
  list.putEnumerated( keyCondition, keyBitmap );
  list.putEnumerated( keyCondition, keyGrayscale );
  list.putEnumerated( keyCondition, keyDuotone );
  list.putEnumerated( keyCondition, keyIndex );
  list.putEnumerated( keyCondition, keyRGB );
  list.putEnumerated( keyCondition, keyCMYK );
  list.putEnumerated( keyCondition, keyLab );
  list.putEnumerated( keyCondition, keyMultichannel );
  descSource.putList( keySourceMode, list );
  var keyDestination = charIDToTypeID( "DstM" );
  var descDest = new ActionDescriptor();
  var keyCMYK = charIDToTypeID( "UCMY" );
  descSource.putObject( keyDestination, keyRGB, descDest );
  executeAction( eventModeChange, descSource, DialogModes.NO );
}


//////////////////////////////////////////////
//////////////////////////////////////////////

Seems to be the engine of the forum swallow the spaces located at random when going advanced editor mode:

The exact line is:

var idT = charIDToTypeID( "T   " );

There are 3 spaces after the T.

Tags: Photoshop

Similar Questions

  • How to save the image that comes from the web.

    Hi friends,

    I have Aproblematique I do a third party application in this application

    I view the images in this app I show that same image in different areas.

    so in this case, I'm each time the download on the net and I display.

    It takes a long time to display images. so, how can I avoid this situation

    Please help me friends.here I don't want to save this image to the device or sd card.

    How to run this task

    I know, if you want to save your image, you can use these methods

    1 hash table

    2 database (BLOB)

    3 file in the SD card or device (using FileConnection)

    Correct me if I'm wrong...

  • How to change the image field captures screenshots automatically from BMP to JPEG

    How to change the image field captures screenshots automatically from BMP to JPEG

    I want to say, when I tap on the screenshot on my keyboard and paste this image in microsoft photo editor or picasa 3.0 areas of the bitmap .bmp. instead of asking the witch I´d field prefer.
    So, I open that image on the brush to convert it to. JPEG.
    It's hick very!
    is it possible to easily me this step and save or paste pictures in JPEG on my files automatically?

    Hello

    I saw that article when I was looking for one that I posted...

    I understand your problem, and the answer is that, to the best of my knowledge... NO..

    Windows records the capture in memory as bitmap, along with, even if you can paste it directly into a folder, it would be in the form of bitmap...

    The best I could find is to use the suggestion in the link I've included which refers to the

    Windows Key + PrintScreen to automatically record is in PNG format in your pictures folder...

    The only way to do what you want is with a 3rd party capture program that can be configured to save in a directory as a specific file type...

    Personally, I use a program called print screen Deluxe for this... it is a purchased program...

    I'm sure you could find something free to do what you need...

    You may need to use a different key for print screen, but the software can allow you to reprogram the PrntScrn key...

  • How to convert an image from 72 dpi to 300 dpi image?

    How to convert an image from 72 dpi to 300 dpi image?

    Ctrl Alt of the image size I have (Cmd Opt i)

    Uncheck resampling

    Change the resolution

  • How to convert specific images on my Clipboard to text once paste the picture on my .pdf document?

    Hey Adobe experts, I could really use your help.

    I have some screenshots of school I pasted on OneNote. These screenshots have a large amount of text that I could use. I created a large .pDF document where I saved my notes and text. Now - how to convert the SPECIFIC images that I stick to the text document? I use the word 'Specific' here because I know I can run OCR on a blank page without any text. But how to do OCR on an image

    It automatically happened a couple of times when I tried to save the document immediately after I pasted the image - when I was under "Edit PDF" I was able to edit and change the fonts of the text. But how can I do this at will? Is there a special button somewhere?

    P.S. I already tried to OCR - but it's only limited to pages without already "renderable text".

    I use Adobe Acrobat Pro DC; 8.1 Windows machine

    Hi SinNombre,

    If you are referring to perform OCR on a page with the image and the renderable text, it is not supported. However, you can use the following workaround for the same thing:

    1. print the PDF document to Microsoft XPS Document Writer or accessing the file-> export to...-> Image-> (an example of TIFF or PNG format)

    2 convert the output created in PDF format. This PDF file contains all the texts and images in the form of images.

    3. run the OCR on this PDF.

    This should solve your problem

  • I just purchased photos to shutterstock and they said, it will download as a .eps file. They said that I need vector editor like adobe illustrator to convert the image to the jpeg format. Could someone tell me how to proceed? This is all very alien to me.

    I just purchased photos to shutterstock and they said, it will download a .eps file. They said that I need vector editor like adobe illustrator to convert the image to the jpeg format. Could someone advise me on how to do this? This is all very alien to me.

    The chic Lady

    File > open to open your eps file

    File > export to export your image as a jpg.

    In the export dialog just below where you type the name of the file is a type of file, which is where you choose jpg.

    Whatever you do, do not delete the eps file. If you need to access the original you have.

    I recommend instead of jpg you choose psd, tiff, or png and jpg don't use that to share. Jpg is a lossy format, which means that whenever you modify the file and save it, degrades the quality of this file. The formats that I recommend are lossless formats, you can edit all you want that data is not being ignored, unless you choose to do so.

  • How to open GROSS of DSC_RX100M3 images?  I downloaded Adobe DNG converter 8.4, but not able to convert the images?

    How to open GROSS of DSC_RX100M3 images?  I downloaded Adobe DNG converter 8.4, but not able to convert the images?

    Minor correction to what SSprengel wrote...

    The RX100M3 is supported only by version 8.5.  Looks like you need a newer version.

    Using Photoshop | Digital Negative (DNG)

    -Christmas

  • How to display the Image caught by IMAQdx in CWIMAQViewer in VC ++ 6.0?

    Hello

    I use VC ++ 6.0 and NIIMAQdx (Vision 8.5 Acquisition) to get the picture from my camera Prosilica GigE GE1380.  The definition of the image being entered is

    Image * grabImg;

    Later, I want to display in a CWIMAQViewer control. However, given that my grabImg is not of type CWIMAQImage, I get errors that.

    Anyone know how I can do? If you have an idea, please help me. I spent several days on this issue...

    Thank you!

    AY

    Hi, for this type of image you must call the imaqDisplayImage (which will actually create a new window). Alternatively, you can convert the image to a CWIMAQImage type (for example with the ArrayToImage of the class CWIMAQImage method. Discover the shipping documents in C:\Program NIUninstaller Instruments\Vision\Documentation and C:\Program NIUninstaller Instruments\NI-IMAQdx\Docs.

  • How to convert an image large parts of images? means split a jpg to several sub vivid image. (this sub image can partner in this big picture)

    Hi friends...

    How to convert an image large parts of images? means split a jpg to several sub vivid image. (this subimages can partner in this great image) any help

    In the example, I created both images and them added together, and the reverse can be done in the same way.

  • How to change the Image the Image (8 bit) (32 bit)?

    Dear all,

    I have a question about VISION.

    An Image from IMAQ USB Grab Acquire.vi is 32-bit, even if the IMAQ Creat.vi has the type U8 value.
    But the more IMAQ vi (for example IMAQ get LCD ROI.vi) can only deal with 8-bit Image.
    How to change the Image from 32-bit to 8-bit Image?
    Thank you!

    Hugo

    Hi Hugo,.

    You use a color camera? coz usually 32 bit for a color image.

    If so, you can try the unique color Pane.vi extract to extract its Luminance component. It then becomes an 8-bit grayscale image.

    Zheng OR AE

  • How to determine the image type in IMAQdx

    You can use the property IMAQ node to determine the image type when creating images.  However, when I try with IMAQdx I get 0 bits per pixel and I do not see a type as for IMAQ image.  I am creating 8-bit images when my camera is color.  How can I determine the image type of the camera file?

    Hi rammer,.

    IMAQdx exposes an attribute called "TypeOfImageInUse" that will give you the image type expected for the current settings of the camera. However, none of the functions that return an image IMAQdx will automatically convert the image to the format automatically, so you don't normally have to worry about this.

    I do not believe that the attribute is now directly exposed as his own property node, but you can use the CameraAttributes-> ActiveAttribute/ValueU32 those for questioning as any other attribute of dynamic camera.

    Eric

  • The image display memory from the phone to my apps?

    Hi all

    You want to get the image of the phone memory and display the selected image in my applications.

    1. I get the path of the image to the selected image memory of the phone.

    2 How to display the image at my applications using the path of the selected image?

    Please let me know how to achieve this.

    Kind regards

    NGO

    Hi all

    Thanks for your reply...

    http://StackOverflow.com/questions/8982893/how-i-can-get-image-from-Gallery-in-BlackBerry

    My requirement is already set at the link above...

    Kind regards

    NGO

  • How to export the JPEG to CMYK in LR3?

    How to export the JPEG to CMYK in LR3?

    You pouvez save a JPEG file to CMYK from the printing in LR6 Module.

  • Please how to convert the photo to the second

    2012-Kia-Rio-SX-side1.jpg11707850_10153403835594354_514303523436587694_n-1.jpg

    Please guys how to convert the kia rio pictures the second perfect like this, and with any program, I know that all steps in details please its very important

    That looks just like you would use the tool pen to redraw on the image and create shape layers (black areas). It could be done in Photoshop or Illustrator.

    Using Photoshop | Draw with the pen tools

  • How to convert my raw Filws extracted from my new Nikon d750 camera using Photoshop elements 11?

    How to convert my raw Filws extracted from my new Nikon d750 camera using Photoshop elements 11? How to convert my

    The D750 is not yet supported. It may be a few weeks before Adobe proposes an update to the latest versions of Photoshop/Elements. Perhaps in October/November.

    They generally provide a pre-release version of a few weeks in advance (any day now, I hope), but as far as I KNOW, they do not usually work on Photoshop Elements.

Maybe you are looking for