overwrite files with scripts
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2008 11:47 AM
I need to resize, adjust and overwrite uploaded photos.
I cannot find documentation on how to save the image back over itself.
I have so far
var newImage = document.transformImage("image/jpeg","-normalize -resize 1024x768", document.parent);
This gives me an error about the file existing.
I cannot find documentation on how to save the image back over itself.
I have so far
var newImage = document.transformImage("image/jpeg","-normalize -resize 1024x768", document.parent);
This gives me an error about the file existing.
Labels:
- Labels:
-
Archive
3 REPLIES 3

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2008 05:06 AM
I'd suggest you rename the old image, write the new image, and then delete the renamed old image (rename old image instead of deleting in case something goes wrong and you need to retry).
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2008 05:26 PM
So I have gotten this far:
// "-normalize -resize 1024x768",
var strOrigName = document.properties.name;
var tmpName = "resized_" + document.properties.name;
document.properties.name = tmpName;
var rImage=document.transformImage("image/jpeg","-normalize -resize 1024x768", document.parent);
if (rImage){
document.properties.name = strOrigName;
document.save();
//document.remove();
}
The documentation does not seem to give any way to access specific known docs. So I can rename and save the new resizedimage, but cannot figure out how to delete the old file nor can I figure out how to rename the new document. I am very familiar with javascript and maybe I am too clouded by regular web scripting to see how this works.
The errors I get state nodeRef is required, but I cannot find anyway to obtain a nodeRef.
// "-normalize -resize 1024x768",
var strOrigName = document.properties.name;
var tmpName = "resized_" + document.properties.name;
document.properties.name = tmpName;
var rImage=document.transformImage("image/jpeg","-normalize -resize 1024x768", document.parent);
if (rImage){
document.properties.name = strOrigName;
document.save();
//document.remove();
}
The documentation does not seem to give any way to access specific known docs. So I can rename and save the new resizedimage, but cannot figure out how to delete the old file nor can I figure out how to rename the new document. I am very familiar with javascript and maybe I am too clouded by regular web scripting to see how this works.
The errors I get state nodeRef is required, but I cannot find anyway to obtain a nodeRef.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2008 08:55 AM
I just tried deleting nodes and it works, using remove() or document.removeNode. I did get exceptions throwin in the UI, but that is because after you delete "document", it tries to come back to properties sheet, but the document no longer exists. so you need to make sure you run the script not from the document itself, but from some other place. find the node you want using search.
