PSD-Tutorials.de
Forum für Design, Fotografie & Bildbearbeitung
Tutkit
Agentur
Hilfe
Kontakt
Start
Forum
Aktuelles
Besonderer Inhalt
Foren durchsuchen
Tutorials
News
Anmelden
Kostenlos registrieren
Aktuelles
Suche
Suche
Nur Titel durchsuchen
Von:
Menü
Anmelden
Kostenlos registrieren
App installieren
Installieren
JavaScript ist deaktiviert. Für eine bessere Darstellung aktiviere bitte JavaScript in deinem Browser, bevor du fortfährst.
Du verwendest einen veralteten Browser. Es ist möglich, dass diese oder andere Websites nicht korrekt angezeigt werden.
Du solltest ein Upgrade durchführen oder einen
alternativen Browser
verwenden.
Antworten auf deine Fragen:
Neues Thema erstellen
Start
Forum
Bildbearbeitung (2D), Vektor- & Layoutbearbeitung
Photoshop
Text-Files automatisch in TIFF oder PSD konvertieren
Beitrag
<blockquote data-quote="HaraldL" data-source="post: 1420558" data-attributes="member: 396620"><p><strong>AW: Text-Files automatisch in TIFF oder PSD konvertieren</strong></p><p></p><p>Danke für Eure Antworten, ich habe leider erst jetzt wieder hier rein geschaut, weil mir nicht klar war, dass ich nur für die erste Antwort eine Mail bekomme...SORRY, war sehr in Hektik gestern ;-)</p><p></p><p>Mit Aktionen in PS habe ich es nicht hinbekommen, da mir nicht klar ist, wie ich damit automatisch TXT-Files einlesen können soll, aber das liegt vor allem daran, dass meine PS-Kenntnisse da nicht ausreichen und ich nicht mehr Zeit investieren konnte. Wenn mir das aber jemand präziser erläutern würde, wär ich sehr happy drüber, da es mich natürlich sehr interessiert.</p><p></p><p>ich habe mir ein Java-Programm geschrieben, dass das für mich erledigt, das war für mich der schnellste Weg, da ich darin die meiste Erfahrung habe...</p><p></p><p>Prinzipiell ging es immer um kurzen einzeiligen Text, einmal linksbündig und einmal rechtsbündig in ein Template.tif mit transparentem Hintergrund einzufügen. Das ganze aber ca. 700-800 mal und"alle Jahre wieder"</p><p></p><p>Falls mal jemand sowas braucht, hier ist der Code (ist aber nur ein Proof of Concept und auch als solches zu sehen ;-)</p><p></p><p></p><p>import java.awt.Color;</p><p>import java.awt.Font;</p><p>import java.awt.FontMetrics;</p><p>import java.awt.Graphics2D;</p><p>import java.awt.RenderingHints;</p><p>import java.awt.image.BufferedImage;</p><p>import java.awt.image.renderable.ParameterBlock;</p><p>import java.io.File;</p><p>import java.io.FileOutputStream;</p><p>import java.io.IOException;</p><p></p><p>import javax.imageio.ImageIO;</p><p>import javax.media.jai.JAI;</p><p>import javax.media.jai.RenderedOp;</p><p></p><p>import com.itextpdf.text.Anchor;</p><p>import com.itextpdf.text.Chunk;</p><p>import com.itextpdf.text.Document;</p><p>import com.itextpdf.text.DocumentException;</p><p>import com.itextpdf.text.Paragraph; // import com.itextpdf.text.html.HtmlWriter;</p><p>import com.itextpdf.text.pdf.PdfWriter;</p><p>import com.sun.media.jai.codec.FileSeekableStream; // import com.itextpdf.text.rtf.RtfWriter2;</p><p>import com.sun.media.jai.codec.TIFFDecodeParam;</p><p></p><p>public class ImageTexter </p><p>{</p><p> private static final int LEFT_RIGHT_BORDER = 10;</p><p> private static final int Y_POS = 38;</p><p> </p><p> private static final int GREY_LEVEL = 200;</p><p> private static final String FONT_NAME = "Arial";</p><p> private static final int FONT_STYLE = Font.PLAIN;</p><p> private static final int FONT_SIZE = 42;</p><p></p><p> public static void main(String[] args) </p><p> {</p><p> try </p><p> {</p><p> final FileSeekableStream stream = new FileSeekableStream(</p><p> "/some/path/to/a/template.tif");</p><p> final TIFFDecodeParam decodeParam = new TIFFDecodeParam();</p><p> decodeParam.setDecodePaletteAsShorts(true);</p><p></p><p> final ParameterBlock params = new ParameterBlock();</p><p> params.add(stream);</p><p> final RenderedOp image1 = JAI.create("tiff", params);</p><p> final BufferedImage img = image1.getAsBufferedImage();</p><p></p><p> final Graphics2D g2 = img.createGraphics();</p><p></p><p> final Font font = new Font(FONT_NAME, FONT_STYLE, FONT_SIZE);</p><p> </p><p> g2.setColor( new Color(GREY_LEVEL,GREY_LEVEL,GREY_LEVEL));</p><p> g2.setFont(font);</p><p></p><p> final FontMetrics fm = g2.getFontMetrics();</p><p> g2.setRenderingHint(RenderingHints.KEY_ANTIALIASIN G, </p><p> RenderingHints.VALUE_ANTIALIAS_ON);</p><p></p><p> final String leftText = "Harald Loeffler";</p><p> final String rightText = "Origami";</p><p> </p><p> final int imageWidth = img.getWidth();</p><p> final int imageHeight = img.getHeight();</p><p> </p><p> final int rightTextHeight = (int)fm.getStringBounds(rightText, g2).getHeight();</p><p> final int leftTextHeight = (int)fm.getStringBounds(leftText, g2).getHeight();</p><p> final int textHeight = Math.max(rightTextHeight, leftTextHeight);</p><p> </p><p> final int rightTextWidth = (int)fm.getStringBounds(rightText, g2).getWidth();</p><p> </p><p> final int top_border = (imageHeight - textHeight) / 2;</p><p> </p><p> g2.drawString(leftText, LEFT_RIGHT_BORDER, top_border + textHeight);</p><p> g2.drawString(rightText, imageWidth - LEFT_RIGHT_BORDER - rightTextWidth, Y_POS);</p><p></p><p> final File outputfile = new File(</p><p> "/some/path/to/an/output.png");</p><p> </p><p> ImageIO.write(img, "png", outputfile);</p><p></p><p> } </p><p> catch (IOException e) </p><p> {</p><p> e.printStackTrace();</p><p> }</p><p> }</p><p>}</p></blockquote><p></p>
[QUOTE="HaraldL, post: 1420558, member: 396620"] [b]AW: Text-Files automatisch in TIFF oder PSD konvertieren[/b] Danke für Eure Antworten, ich habe leider erst jetzt wieder hier rein geschaut, weil mir nicht klar war, dass ich nur für die erste Antwort eine Mail bekomme...SORRY, war sehr in Hektik gestern ;-) Mit Aktionen in PS habe ich es nicht hinbekommen, da mir nicht klar ist, wie ich damit automatisch TXT-Files einlesen können soll, aber das liegt vor allem daran, dass meine PS-Kenntnisse da nicht ausreichen und ich nicht mehr Zeit investieren konnte. Wenn mir das aber jemand präziser erläutern würde, wär ich sehr happy drüber, da es mich natürlich sehr interessiert. ich habe mir ein Java-Programm geschrieben, dass das für mich erledigt, das war für mich der schnellste Weg, da ich darin die meiste Erfahrung habe... Prinzipiell ging es immer um kurzen einzeiligen Text, einmal linksbündig und einmal rechtsbündig in ein Template.tif mit transparentem Hintergrund einzufügen. Das ganze aber ca. 700-800 mal und"alle Jahre wieder" Falls mal jemand sowas braucht, hier ist der Code (ist aber nur ein Proof of Concept und auch als solches zu sehen ;-) import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.awt.image.renderable.ParameterBlock; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import javax.imageio.ImageIO; import javax.media.jai.JAI; import javax.media.jai.RenderedOp; import com.itextpdf.text.Anchor; import com.itextpdf.text.Chunk; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.Paragraph; // import com.itextpdf.text.html.HtmlWriter; import com.itextpdf.text.pdf.PdfWriter; import com.sun.media.jai.codec.FileSeekableStream; // import com.itextpdf.text.rtf.RtfWriter2; import com.sun.media.jai.codec.TIFFDecodeParam; public class ImageTexter { private static final int LEFT_RIGHT_BORDER = 10; private static final int Y_POS = 38; private static final int GREY_LEVEL = 200; private static final String FONT_NAME = "Arial"; private static final int FONT_STYLE = Font.PLAIN; private static final int FONT_SIZE = 42; public static void main(String[] args) { try { final FileSeekableStream stream = new FileSeekableStream( "/some/path/to/a/template.tif"); final TIFFDecodeParam decodeParam = new TIFFDecodeParam(); decodeParam.setDecodePaletteAsShorts(true); final ParameterBlock params = new ParameterBlock(); params.add(stream); final RenderedOp image1 = JAI.create("tiff", params); final BufferedImage img = image1.getAsBufferedImage(); final Graphics2D g2 = img.createGraphics(); final Font font = new Font(FONT_NAME, FONT_STYLE, FONT_SIZE); g2.setColor( new Color(GREY_LEVEL,GREY_LEVEL,GREY_LEVEL)); g2.setFont(font); final FontMetrics fm = g2.getFontMetrics(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASIN G, RenderingHints.VALUE_ANTIALIAS_ON); final String leftText = "Harald Loeffler"; final String rightText = "Origami"; final int imageWidth = img.getWidth(); final int imageHeight = img.getHeight(); final int rightTextHeight = (int)fm.getStringBounds(rightText, g2).getHeight(); final int leftTextHeight = (int)fm.getStringBounds(leftText, g2).getHeight(); final int textHeight = Math.max(rightTextHeight, leftTextHeight); final int rightTextWidth = (int)fm.getStringBounds(rightText, g2).getWidth(); final int top_border = (imageHeight - textHeight) / 2; g2.drawString(leftText, LEFT_RIGHT_BORDER, top_border + textHeight); g2.drawString(rightText, imageWidth - LEFT_RIGHT_BORDER - rightTextWidth, Y_POS); final File outputfile = new File( "/some/path/to/an/output.png"); ImageIO.write(img, "png", outputfile); } catch (IOException e) { e.printStackTrace(); } } } [/QUOTE]
Bilder bitte
hier hochladen
und danach über das Bild-Icon (Direktlink vorher kopieren) platzieren.
Zitate einfügen…
Authentifizierung
Wenn ★ = 12, ◇ = 4 und die Hälfte von ★ zu ◇ addiert wird, was ist das Ergebnis?
Antworten
Start
Forum
Bildbearbeitung (2D), Vektor- & Layoutbearbeitung
Photoshop
Text-Files automatisch in TIFF oder PSD konvertieren
Oben