You don’t mention which platform you are using, but given your “command line” reference I will assume GNU/Linux. What you require is not simple to do if you only want some images altered in the manner described. If you want all images altered in this manner, then a basic hack of the XML is possible. You will need to write a script to:
- Extract (unzip)
content.xml from the ODT.
- Change the
text:anchor-type attribute of each
draw:frame element with a
draw:name="graphicsN" attribute in
- Replace (rezip)
content.xml back in the ODT.
Note that images anchored “As character” as automatically aligned left, while images anchored “To paragraph” are automatically centre aligned. Bash script would look something like:
# change anchoring of all <draw:frame> elements from "as-char" to "paragraph"
# args: 1 = full ODT file name
rm -f $f_copy;
cp $1 $f_copy;
unzip $f_copy content.xml;
sed -i 's/draw:frame\(.*\)draw:name=\"graphics\(.*\)as-char/draw:frame\1draw:name=\"graphics\2paragraph/g' content.xml;
zip -fq $f_copy content.xml;
\(.*\) expression is a capturing group, which is substituted back in to the replacement string with
\2. This is a crude replacement method that does not guarantee all settings will be as required in the resulting document. The document is copied however so it won’t ruin your original.