CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/icons/convert-to-png.sh
Views: 1401
# Copyright (C) 2014 Sergio Benjamim12# This program is free software; you can redistribute it and/or modify3# it under the terms of the GNU General Public License as published by4# the Free Software Foundation; either version 2, or (at your option)5# any later version.67# This program is distributed in the hope that it will be useful,8# but WITHOUT ANY WARRANTY; without even the implied warranty of9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10# GNU General Public License for more details.1112# You should have received a copy of the GNU General Public License13# along with this program; if not, write to the Free Software Foundation,14# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.1516# Very simple bash script to convert svg to png files, you can choose inkscape or imagemagick ('convert' command) and the path to icons export.17# Only converts icons/icon-512.svg18# Needs improvement, yeah, i know, it is not so good... at least it work :)192021#!/bin/bash2223# Parameters:24# -s, --software inkscape | imagemagick --> "./convert-to-png.sh -s imagemagick" for example25# -d, --directory directory path --> "./convert-to-png.sh -d /usr/share/icons/hicolor/" or "./convert-to-png.sh -d ../../debian/ppsspp/usr/share/icons/hicolor/" for example2627# Default options28software_option="inkscape" # sometimes imagemagick does not convert very well, so inkscape is default29path="icons" # i.e. icons/icons/3031echo -e3233while [ "$1" != "" ]; do34case $1 in35-s | --software ) shift36if [ "$1" == "inkscape" ] || [ "$1" == "imagemagick" ]; then37software_option=$138echo -e "Using $1.\n"39else40software_option="inkscape"41echo -e "This parameter does not exist, inkscape or imagemagick are valids parameters. Using Inkscape.\n"42fi43;;4445-d | --directory ) shift46path=$147path=${path%"/"}48;;4950* ) echo -e "Error with parameters.\n"51exit 152;;53esac54shift55done565758# Creating icons/icons/ if user does not choose any directory59if [ "$path" == "icons" ] && [ ! -d "$path" ]; then60mkdir icons/61fi626364# Converting svg icons to png:6566# 16 pixel icon use other icon, resize does not fit well for small icons67if [ "$software_option" == "inkscape" ]; then68if [ "$path" == "icons" ]; then69inkscape --export-area-page --file=icon-16.svg --export-png=$path/ppsspp_16.png70else71inkscape --export-area-page --file=icon-16.svg --export-png=$path/16x16/apps/ppsspp.png72fi73elif [ "$software_option" == "imagemagick" ]; then74if [ "$path" == "icons" ]; then75convert icon-16.svg -transparent white $path/ppsspp_16.png76else77convert icon-16.svg -transparent white $path/16x16/apps/ppsspp.png78fi79fi8081x="x"8283for size in 24 32 48 64 96 128 256 51284do85if [ "$software_option" == "inkscape" ]; then86if [ "$path" == "icons" ]; then87inkscape --export-area-page --export-width=$size --export-height=$size --file=icon-512.svg --export-png=$path/ppsspp_$size.png88else89inkscape --export-area-page --export-width=$size --export-height=$size --file=icon-512.svg --export-png=$path/$size$x$size/apps/ppsspp.png90fi91elif [ "$software_option" == "imagemagick" ]; then92if [ "$path" == "icons" ]; then93convert icon-512.svg -resize $size -transparent white $path/ppsspp_$size.png94else95convert icon-512.svg -resize $size -transparent white $path/$size$x$size/apps/ppsspp.png96fi97fi98done99100echo -e "\nIcons was exported to $path/ folder.\n"101102103exit 0104105106