Implement batch conversion images with awk

xiaoxiao2021-03-05  18

Write a drawing flower with GTK, I feel that the graphics drawn from "wrong" is quite good, so many screenshots are preserved. But because the screenshot is PNG format, let me be speechless, the website such as blog.9cbs.net does not support the PNG format, and must only be converted into a GIF format. Conversion can be implemented with command convers.png image.gif. Now there is a lot of pictures, so I think I want to use awk.

The AWK code is as follows:

# Convert .png Image to .gif Image # 2005.4.12 Benbear ## usage: # ls | awk -fpng2gif.awk ## NEED: # Bash # Convert # $ 0 ~ //. PNG $ / {GIF = SUBSTR ($ 0, 0, Length ($ 0) -4) ".gif"; System ("Test -R" GIF "|| Convert" $ 0 "" gif);

$ 0 ~ //. PNG $ / is a line that matches the end of .png, that is, the extension is the file called .png, ie the PNG picture. Then ask the name of the GIF file from $ 0. SYSTEM execution is that if there is a GIF image, the following CONVERT command is not executed; otherwise, Convert conversion.

转载请注明原文地址:https://www.9cbs.com/read-36778.html

New Post(0)