Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Is this even possible?

Return to Forums

  • Author
    Posts
    • #93725
      Zaem Nabi
      Member

      A script that will-

      -open an Id file (or, alternatively put a png file as the background layer)
      -prompt the user to choose 5 images (or alternatively pick out the folder which has the images in there)
      -place those images in a predetermined location
      -export the project as a png or Jpeg

      I have looked at the image catalogue script which is so extremely close to this but I can’t figure out how to have it place the images on a “template” that I have made.

      Any help would be amazing

    • #93751
      Anonymous
      Inactive

      Wow my answer just disappeared on posting :(

      var main = function() {
      	var template = getTemplate(),
      	files;
      	
      	if ( !template ) return;
      	files = getFiles ();
      	if ( !files || !files.length ) return;
      	
      	makeDocument ( template, files );
      }
      
      var getTemplate = function() {
      	var mac = $.os[0]=="M",
      	macFilter = function(f){
      		return (f instanceof Folder) || /\.indt$/i.test(f.name);
      	},	
      	winFilter = "InDesign templates : *.indt;",
      	filter = mac? macFilter : winFilter,
      	template = File.openDialog ( "Please choose a template", filter );
      	return template;
      }
      
      var getFiles = function() {
      	var mac = $.os[0]=="M",
      	macFilter = function(f){
      		return (f instanceof Folder) || /\.(jpe?g|tiff?|png)$/i.test(f.name);
      	},	
      	winFilter = "Image Files (*.png, *.jpg, *.jpeg, *.tif)",
      	filter = mac? macFilter : winFilter,
      	files = File.openDialog ( "Please select some files…", filter, true );
      	return files
      }
      
      var makeDocument = function(template, files) {
      	var doc = app.open ( template, false ),
      	root = doc.xmlElements[0],
      	img,
      	n = files.length, i = 0;
      	
      	while ( i<n ) {
      		img = root.xmlElements[i];
      		if ( img.isValid )  {
      			img.xmlContent.place ( files[i] );
      		};
      		
      		i++;
      	}
      	
      	jpgFile = File ( Folder.desktop+"/"+doc.name+".jpg" );
      	doc.exportFile ( ExportFormat.JPG, jpgFile );
      	doc.close(SaveOptions.NO);
      
      }
      
      
      var u;
      
      
      app.doScript ( "main()",u,u,UndoModes.ENTIRE_SCRIPT, "The Script" );
      
    • #93762
      David Blatner
      Keymaster

      Loic, sorry your reply disappeared. That sometimes happens on our forums. It was “held for moderation.” If it happens again, just email me and I will fix it.

      Also, I edited your post above to use the “pre” html tags before and after, so that it appears correctly.

    • #93765
      Anonymous
      Inactive

      Thanks a lot David. Actually I tried to use

       tags but as the post disappeared I thought it could have been due to those understood tags :P
    • #93766
      Anonymous
      Inactive

      I also realized that the snippet is only interesting if sided with the template I used :P
      https://www.filedropper.com/tutu

Viewing 4 reply threads
  • You must be logged in to reply to this topic.
Forum Ads