Copy link to clipboard
Copied
anyone have idea about how we can covert .ai image into base64 using extend script?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I'm not sure what this has to do with scripting. The file needs to exist in some form already and then you can use whatever is your favorite encoding/ packaging tool like WinZip. Otherwise you can encode individual strings in the file using the normal functions provided by the scripting engine.
Mylenium
Copy link to clipboard
Copied
I have extend script for saveasPDF but i need extend script for saveasBase64...
try {
// uncomment to suppress Illustrator warning dialogs
// app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
if (app.documents.length > 0 ) {
// Get the folder to save the files into
var destFolder = null;
destFolder = Folder.selectDialog( 'Select folder for PDF files.', '~' );
if (destFolder != null) {
var options, i, sourceDoc, targetFile;
// Get the PDF options to be used
options = this.getOptions();
// You can tune these by changing the code in the getOptions() function.
for ( i = 0; i < app.documents.length; i++ ) {
sourceDoc = app.documents[i]; // returns the document object
// Get the file to save the document as pdf into
targetFile = this.getTargetFile(sourceDoc.name, '.pdf', destFolder);
// Save as pdf
sourceDoc.saveAs( targetFile, options );
}
alert( 'Documents saved as PDF' );
}
}
else{
throw new Error('There are no document open!');
}
}
catch(e) {
alert( e.message, "Script Alert", true);
}
/** Returns the options to be used for the generated files.
@Return PDFSaveOptions object
*/
function getOptions()
{
// Create the required options object
var options = new PDFSaveOptions();
// See PDFSaveOptions in the JavaScript Reference for available options
// Set the options you want below:
// For example, uncomment to set the compatibility of the generated pdf to Acrobat 7 (PDF 1.6)
// options.compatibility = PDFCompatibility.ACROBAT7;
// For example, uncomment to view the pdfs in Acrobat after conversion
// options.viewAfterSaving = true;
return options;
}
/** Returns the file to save or export the document into.
@Param docName the name of the document
@Param ext the extension the file extension to be applied
@Param destFolder the output folder
@Return File object
*/
function getTargetFile(docName, ext, destFolder) {
var newName = "";
// if name has no dot (and hence no extension),
// just append the extension
if (docName.indexOf('.') < 0) {
newName = docName + ext;
} else {
var dot = docName.lastIndexOf('.');
newName += docName.substring(0, dot);
newName += ext;
}
// Create the file object to save to
var myFile = new File( destFolder + '/' + newName );
// Preflight access rights
if (myFile.open("w")) {
myFile.close();
}
else {
throw new Error('Access is denied');
}
return myFile;
}
Copy link to clipboard
Copied
I want to save any .ai image into jepg/base64 format after opening it in illustrator's extension so please guide me on this?
e.g.
step1: open adobe illustrator
step2: then open any already saved image from local folder into illustrator
step3: add new layer and also add some comments on the image via text tool bar
step4: "MY QUESTION" how i can save this .ai image into jpeg and base64?
please guide me on this.
Copy link to clipboard
Copied
Hello @Rishabh22425292b5db,
Thanks for reaching out. Kindly try the suggestions shared in this community post (https://community.adobe.com/t5/illustrator-discussions/how-can-i-encode-a-file-into-a-base-64/td-p/1...) and check if it helps.
Looking forward to your response.
Thanks,
Anubhav
Copy link to clipboard
Copied
No its not helped.
I want to add a script to save .ai image to base64(which should contain layer automatically).
file->script->saveasBase64 <= need to implement this
Copy link to clipboard
Copied
Basically anyone have idea about how we can covert .ai file into base64 using extend script?
Copy link to clipboard
Copied
This question is meaningless.
.ai, .pdf, .jpg are image file formats. Base64 is not an image file format. It is a general method for encoding data, like ROT13 or ZIP.
https://en.wikipedia.org/wiki/Base64
Is your goal to save your .ai artwork to a .jpg file, then encode that .jpg file’s contents as Base64 data? To export as JPEG, use AI’s ‘export’ command.
To convert the bitmap image to Base64-encoded text in macOS’s Terminal.app:
base64 your-image.jpg > your-image-base64.txt
I expect Windows’ PowerShell has something equivalent.
Copy link to clipboard
Copied
You keep saying "convert to base 64". This is no help at all, please stop repeating it, we've told you this means nothing. But I think in one post you accidentally said what you really want; base 64 encoded JPEG. Is that correct? If so of course it cannot have layers.