-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrgb2cmyk
36 lines (34 loc) · 2.39 KB
/
rgb2cmyk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
####COPYRIGHT NOTICE#####COPYRIGHT NOTICE#####COPYRIGHT NOTICE#####COPYRIGHT NOTICE#####COPYRIGHT NOTICE#####COPYRIGHT NOTICE####
#Copyright (C) 2018 exarobibliologst (github.com/exarobibliologist) #
# #
#This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License #
#as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. #
# #
#This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of #
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. #
# #
#You should have received a copy of the GNU General Public License along with this program; if not, write to the #
#Free Software Foundation, Inc. #
#51 Franklin Street, Fifth Floor, #
#Boston, MA 02110-1301, USA. #
#################################################################################################################################
function rgb2cmyk()
{
echo "Input Red 0-255"
read red
echo "Input Green 0-255"
read green
echo "Input Blue 0-255"
read blue
computedC=$(echo "1-($red/255)" | bc)
computedM=$(echo "1-($green/255)" | bc)
computedY=$(echo "1-($blue/255)" | bc)
array="${computedC}\n${computedM}\n${computedY}"
minCMY=$(echo -e "${array}" | sort -n | head -n1)
theC=$(echo "($computedC - $minCMY) / (1 - $minCMY)" | bc)
theM=$(echo "($computedM - $minCMY) / (1 - $minCMY)" | bc)
theY=$(echo "($computedY - $minCMY) / (1 - $minCMY)" | bc)
clear
echo -e "The RGB color $red / $green / $blue\nis\nC=$theC\nM=$theM\nY=$theY\nK=$minCMY"
}