Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated project #7

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
All emoji assets are not owned by me but copyrighted by their respective owner:
Copyright (c) 2012 Apple Inc. All rights reserved.
52 changes: 34 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
## emoji-extractor

extracts high-resolution emoji pngs from `/System/Library/Fonts/Apple Color Emoji.ttf`

### usage

```
$ file /System/Library/Fonts/Apple\ Color\ Emoji.ttf
/System/Library/Fonts/Apple Color Emoji.ttf: TrueType font data

$ ruby emoji_extractor.rb

$ ls images
20x20 32x32 40x40 48x48 64x64 96x96 160x160

$ file images/160x160/1.png
images/160x160/1.png: PNG image data, 160 x 160, 8-bit/color RGBA, non-interlaced
```
## emoji-extractor

This is a small ruby script that extracts the Apple Color Emoji PNG Symbols from their corresponding system font located at `/System/Library/Fonts/Apple Color Emoji.ttf`. The extracted assets will be placed in a subfolder for each resolution in a subfolder called "image" in the containing folder. File system structure as follows:
```
.
├── README.md
├── emoji_extractor.rb
└── images
├── 160x160
├── 20x20
├── 21x21
├── 32x32
├── 40x40
├── 48x48
├── 64x64
└── 96x96
```
It was updated to work with current versions of ruby and include assets for the new emojis as introduced in OS X 10.10.3 / iOS 8.3 (defined in Unicode standard 7.0).

### usage

Just run the ruby script, no arguments need to be passed. It will check for the Apple Color Emoji.ttf at it's default location, so you should make shure that it exists.
```
$ file /System/Library/Fonts/Apple\ Color\ Emoji.ttf
/System/Library/Fonts/Apple Color Emoji.ttf: TrueType font data

$ ruby emoji_extractor.rb

$ ls images
20x20 32x32 40x40 48x48 64x64 96x96 160x160

$ file images/160x160/1.png
images/160x160/1.png: PNG image data, 160 x 160, 8-bit/color RGBA, non-interlaced
```
10 changes: 10 additions & 0 deletions Skin colors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
=========================
=== Apple Color Emoji ===
====== Skin Colors ======
=========================
Yellow
White
Light Skinned
Light Intermediate
Dark Intermediate
Black
117 changes: 59 additions & 58 deletions emoji_extractor.rb
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
# stolen largely from http://www.ruby-forum.com/topic/140784

require 'stringio'
require 'fileutils'

def extract_chunk(input, output)
lenword = input.read(4)
length = lenword.unpack('N')[0]
type = input.read(4)
data = length>0 ? input.read(length) : ""
crc = input.read(4)
return nil if length<0 || !(('A'..'z')===type[0,1])
#return nil if validate_crc(type+data, crc)
output.write lenword
output.write type
output.write data
output.write crc
return [type, data]
end

def extract_png(input)
buf = StringIO.new
hdr = input.read(8)
raise "Not a PNG File" if hdr[0,4]!= "\211PNG"
raise "file not in binary mode" if hdr[4,4]!="\r\n\032\n"
buf.write(hdr)

height, width = 0, 0

loop do
chunk_type, chunk_data = extract_chunk(input,buf)
height, width = chunk_data.unpack('NN') if chunk_type == 'IHDR'
break if chunk_type.nil? || chunk_type == 'IEND'
end

FileUtils.mkdir_p(dir = "images/#{height}x#{width}")
if @prev != dir
@n = 0
@prev = dir
end

buf.rewind
ofp = File.new("#{dir}/#{@n+=1}.png","wb")
ofp.write buf.read
ofp.close
end

ttf = File.new("/System/Library/Fonts/Apple Color Emoji.ttf","rb")
ttf_data = ttf.read

pos = 0
while m = /\211PNG/.match(ttf_data[pos..-1])
raise "no PNG found" if !m
pos += m.begin(0) + 1
ttf.seek(pos-1)

extract_png(ttf)
end
# encoding: US-ASCII
# stolen largely from http://www.ruby-forum.com/topic/140784

require 'stringio'
require 'fileutils'

def extract_chunk(input, output)
lenword = input.read(4)
length = lenword.unpack('N')[0]
type = input.read(4)
data = length>0 ? input.read(length) : ""
crc = input.read(4)
return nil if length<0 || !(('A'..'z')===type[0,1])
#return nil if validate_crc(type+data, crc)
output.write lenword
output.write type
output.write data
output.write crc
return [type, data]
end

def extract_png(input)
buf = StringIO.new
hdr = input.read(8)
raise "Not a PNG File" if hdr[0,4]!= "\211PNG"
raise "file not in binary mode" if hdr[4,4]!="\r\n\032\n"
buf.write(hdr)

height, width = 0, 0

loop do
chunk_type, chunk_data = extract_chunk(input,buf)
height, width = chunk_data.unpack('NN') if chunk_type == 'IHDR'
break if chunk_type.nil? || chunk_type == 'IEND'
end

FileUtils.mkdir_p(dir = "images/#{height}x#{width}")
if @prev != dir
@n = 0
@prev = dir
end

buf.rewind
ofp = File.new("#{dir}/#{@n+=1}.png","wb")
ofp.write buf.read
ofp.close
end

ttf = File.new("/System/Library/Fonts/Apple Color Emoji.ttf","rb")
ttf_data = ttf.read

pos = 0
while m = /\211PNG/.match(ttf_data[pos..-1])
raise "no PNG found" if !m
pos += m.begin(0) + 1
ttf.seek(pos-1)

extract_png(ttf)
end
Binary file removed images/160x160/.DS_Store
Binary file not shown.
Binary file removed images/160x160/1.png
Binary file not shown.
Binary file removed images/160x160/10.png
Binary file not shown.
Binary file removed images/160x160/100.png
Binary file not shown.
Binary file removed images/160x160/101.png
Binary file not shown.
Binary file removed images/160x160/102.png
Binary file not shown.
Binary file removed images/160x160/103.png
Binary file not shown.
Binary file removed images/160x160/104.png
Binary file not shown.
Binary file removed images/160x160/105.png
Binary file not shown.
Binary file removed images/160x160/106.png
Binary file not shown.
Binary file removed images/160x160/107.png
Binary file not shown.
Binary file removed images/160x160/108.png
Binary file not shown.
Binary file removed images/160x160/109.png
Binary file not shown.
Binary file removed images/160x160/11.png
Binary file not shown.
Binary file removed images/160x160/110.png
Binary file not shown.
Binary file removed images/160x160/111.png
Binary file not shown.
Binary file removed images/160x160/112.png
Binary file not shown.
Binary file removed images/160x160/113.png
Binary file not shown.
Binary file removed images/160x160/114.png
Binary file not shown.
Binary file removed images/160x160/115.png
Binary file not shown.
Binary file removed images/160x160/116.png
Binary file not shown.
Binary file removed images/160x160/117.png
Binary file not shown.
Binary file removed images/160x160/118.png
Binary file not shown.
Binary file removed images/160x160/119.png
Binary file not shown.
Binary file removed images/160x160/12.png
Binary file not shown.
Binary file removed images/160x160/120.png
Binary file not shown.
Binary file removed images/160x160/121.png
Diff not rendered.
Binary file removed images/160x160/122.png
Diff not rendered.
Binary file removed images/160x160/123.png
Diff not rendered.
Binary file removed images/160x160/124.png
Diff not rendered.
Binary file removed images/160x160/125.png
Diff not rendered.
Binary file removed images/160x160/126.png
Diff not rendered.
Binary file removed images/160x160/127.png
Diff not rendered.
Binary file removed images/160x160/128.png
Diff not rendered.
Binary file removed images/160x160/129.png
Diff not rendered.
Binary file removed images/160x160/13.png
Diff not rendered.
Binary file removed images/160x160/130.png
Diff not rendered.
Binary file removed images/160x160/131.png
Diff not rendered.
Binary file removed images/160x160/132.png
Diff not rendered.
Binary file removed images/160x160/133.png
Diff not rendered.
Binary file removed images/160x160/134.png
Diff not rendered.
Binary file removed images/160x160/135.png
Diff not rendered.
Binary file removed images/160x160/136.png
Diff not rendered.
Binary file removed images/160x160/137.png
Diff not rendered.
Binary file removed images/160x160/138.png
Diff not rendered.
Binary file removed images/160x160/139.png
Diff not rendered.
Binary file removed images/160x160/14.png
Diff not rendered.
Binary file removed images/160x160/140.png
Diff not rendered.
Binary file removed images/160x160/141.png
Diff not rendered.
Binary file removed images/160x160/142.png
Diff not rendered.
Binary file removed images/160x160/143.png
Diff not rendered.
Binary file removed images/160x160/144.png
Diff not rendered.
Binary file removed images/160x160/145.png
Diff not rendered.
Binary file removed images/160x160/146.png
Diff not rendered.
Binary file removed images/160x160/147.png
Diff not rendered.
Binary file removed images/160x160/148.png
Diff not rendered.
Binary file removed images/160x160/149.png
Diff not rendered.
Binary file removed images/160x160/15.png
Diff not rendered.
Binary file removed images/160x160/150.png
Diff not rendered.
Binary file removed images/160x160/151.png
Diff not rendered.
Binary file removed images/160x160/152.png
Diff not rendered.
Binary file removed images/160x160/153.png
Diff not rendered.
Binary file removed images/160x160/154.png
Diff not rendered.
Binary file removed images/160x160/155.png
Diff not rendered.
Binary file removed images/160x160/156.png
Diff not rendered.
Binary file removed images/160x160/157.png
Diff not rendered.
Binary file removed images/160x160/158.png
Diff not rendered.
Binary file removed images/160x160/159.png
Diff not rendered.
Binary file removed images/160x160/16.png
Diff not rendered.
Binary file removed images/160x160/160.png
Diff not rendered.
Binary file removed images/160x160/161.png
Diff not rendered.
Binary file removed images/160x160/162.png
Diff not rendered.
Binary file removed images/160x160/163.png
Diff not rendered.
Binary file removed images/160x160/164.png
Diff not rendered.
Binary file removed images/160x160/165.png
Diff not rendered.
Binary file removed images/160x160/166.png
Diff not rendered.
Binary file removed images/160x160/167.png
Diff not rendered.
Binary file removed images/160x160/168.png
Diff not rendered.
Binary file removed images/160x160/169.png
Diff not rendered.
Binary file removed images/160x160/17.png
Diff not rendered.
Binary file removed images/160x160/170.png
Diff not rendered.
Binary file removed images/160x160/171.png
Diff not rendered.
Binary file removed images/160x160/172.png
Diff not rendered.
Binary file removed images/160x160/173.png
Diff not rendered.
Binary file removed images/160x160/174.png
Diff not rendered.
Binary file removed images/160x160/175.png
Diff not rendered.
Binary file removed images/160x160/176.png
Diff not rendered.
Binary file removed images/160x160/177.png
Diff not rendered.
Binary file removed images/160x160/178.png
Diff not rendered.
Binary file removed images/160x160/179.png
Diff not rendered.
Binary file removed images/160x160/18.png
Diff not rendered.
Binary file removed images/160x160/180.png
Diff not rendered.
Binary file removed images/160x160/181.png
Diff not rendered.
Binary file removed images/160x160/182.png
Diff not rendered.
Binary file removed images/160x160/183.png
Diff not rendered.
Binary file removed images/160x160/184.png
Diff not rendered.
Binary file removed images/160x160/185.png
Diff not rendered.
Binary file removed images/160x160/186.png
Diff not rendered.
Binary file removed images/160x160/187.png
Diff not rendered.
Binary file removed images/160x160/188.png
Diff not rendered.
Binary file removed images/160x160/189.png
Diff not rendered.
Binary file removed images/160x160/19.png
Diff not rendered.
Binary file removed images/160x160/190.png
Diff not rendered.
Binary file removed images/160x160/191.png
Diff not rendered.
Binary file removed images/160x160/192.png
Diff not rendered.
Binary file removed images/160x160/193.png
Diff not rendered.
Binary file removed images/160x160/194.png
Diff not rendered.
Binary file removed images/160x160/195.png
Diff not rendered.
Binary file removed images/160x160/196.png
Diff not rendered.
Binary file removed images/160x160/197.png
Diff not rendered.
Binary file removed images/160x160/198.png
Diff not rendered.
Binary file removed images/160x160/199.png
Diff not rendered.
Binary file removed images/160x160/2.png
Diff not rendered.
Binary file removed images/160x160/20.png
Diff not rendered.
Binary file removed images/160x160/200.png
Diff not rendered.
Binary file removed images/160x160/201.png
Diff not rendered.
Binary file removed images/160x160/202.png
Diff not rendered.
Binary file removed images/160x160/203.png
Diff not rendered.
Binary file removed images/160x160/204.png
Diff not rendered.
Binary file removed images/160x160/205.png
Diff not rendered.
Binary file removed images/160x160/206.png
Diff not rendered.
Binary file removed images/160x160/207.png
Diff not rendered.
Binary file removed images/160x160/208.png
Diff not rendered.
Binary file removed images/160x160/209.png
Diff not rendered.
Binary file removed images/160x160/21.png
Diff not rendered.
Binary file removed images/160x160/210.png
Diff not rendered.
Binary file removed images/160x160/211.png
Diff not rendered.
Binary file removed images/160x160/212.png
Diff not rendered.
Binary file removed images/160x160/213.png
Diff not rendered.
Binary file removed images/160x160/214.png
Diff not rendered.
Binary file removed images/160x160/215.png
Diff not rendered.
Binary file removed images/160x160/216.png
Diff not rendered.
Binary file removed images/160x160/217.png
Diff not rendered.
Binary file removed images/160x160/218.png
Diff not rendered.
Binary file removed images/160x160/219.png
Diff not rendered.
Binary file removed images/160x160/22.png
Diff not rendered.
Binary file removed images/160x160/220.png
Diff not rendered.
Binary file removed images/160x160/221.png
Diff not rendered.
Binary file removed images/160x160/222.png
Diff not rendered.
Binary file removed images/160x160/223.png
Diff not rendered.
Binary file removed images/160x160/224.png
Diff not rendered.
Binary file removed images/160x160/225.png
Diff not rendered.
Binary file removed images/160x160/226.png
Diff not rendered.
Binary file removed images/160x160/227.png
Diff not rendered.
Binary file removed images/160x160/228.png
Diff not rendered.
Binary file removed images/160x160/229.png
Diff not rendered.
Binary file removed images/160x160/23.png
Diff not rendered.
Binary file removed images/160x160/230.png
Diff not rendered.
Binary file removed images/160x160/231.png
Diff not rendered.
Binary file removed images/160x160/232.png
Diff not rendered.
Binary file removed images/160x160/233.png
Diff not rendered.
Binary file removed images/160x160/234.png
Diff not rendered.
Binary file removed images/160x160/235.png
Diff not rendered.
Binary file removed images/160x160/236.png
Diff not rendered.
Binary file removed images/160x160/237.png
Diff not rendered.
Binary file removed images/160x160/238.png
Diff not rendered.
Binary file removed images/160x160/239.png
Diff not rendered.
Binary file removed images/160x160/24.png
Diff not rendered.
Binary file removed images/160x160/240.png
Diff not rendered.
Binary file removed images/160x160/241.png
Diff not rendered.
Binary file removed images/160x160/242.png
Diff not rendered.
Binary file removed images/160x160/243.png
Diff not rendered.
Binary file removed images/160x160/244.png
Diff not rendered.
Binary file removed images/160x160/245.png
Diff not rendered.
Binary file removed images/160x160/246.png
Diff not rendered.
Binary file removed images/160x160/247.png
Diff not rendered.
Binary file removed images/160x160/248.png
Diff not rendered.
Binary file removed images/160x160/249.png
Diff not rendered.
Binary file removed images/160x160/25.png
Diff not rendered.
Binary file removed images/160x160/250.png
Diff not rendered.
Binary file removed images/160x160/251.png
Diff not rendered.
Binary file removed images/160x160/252.png
Diff not rendered.
Binary file removed images/160x160/253.png
Diff not rendered.
Binary file removed images/160x160/254.png
Diff not rendered.
Binary file removed images/160x160/255.png
Diff not rendered.
Binary file removed images/160x160/256.png
Diff not rendered.
Binary file removed images/160x160/257.png
Diff not rendered.
Binary file removed images/160x160/258.png
Diff not rendered.
Binary file removed images/160x160/259.png
Diff not rendered.
Binary file removed images/160x160/26.png
Diff not rendered.
Binary file removed images/160x160/260.png
Diff not rendered.
Binary file removed images/160x160/261.png
Diff not rendered.
Binary file removed images/160x160/262.png
Diff not rendered.
Binary file removed images/160x160/263.png
Diff not rendered.
Binary file removed images/160x160/264.png
Diff not rendered.
Binary file removed images/160x160/265.png
Diff not rendered.
Binary file removed images/160x160/266.png
Diff not rendered.
Binary file removed images/160x160/267.png
Diff not rendered.
Binary file removed images/160x160/268.png
Diff not rendered.
Binary file removed images/160x160/269.png
Diff not rendered.
Binary file removed images/160x160/27.png
Diff not rendered.
Binary file removed images/160x160/270.png
Diff not rendered.
Binary file removed images/160x160/271.png
Diff not rendered.
Binary file removed images/160x160/272.png
Diff not rendered.
Binary file removed images/160x160/273.png
Diff not rendered.
Binary file removed images/160x160/274.png
Diff not rendered.
Binary file removed images/160x160/275.png
Diff not rendered.
Binary file removed images/160x160/276.png
Diff not rendered.
Binary file removed images/160x160/277.png
Diff not rendered.
Binary file removed images/160x160/278.png
Diff not rendered.
Binary file removed images/160x160/279.png
Diff not rendered.
Binary file removed images/160x160/28.png
Diff not rendered.
Binary file removed images/160x160/280.png
Diff not rendered.
Binary file removed images/160x160/281.png
Diff not rendered.
Binary file removed images/160x160/282.png
Diff not rendered.
Binary file removed images/160x160/283.png
Diff not rendered.
Binary file removed images/160x160/284.png
Diff not rendered.
Binary file removed images/160x160/285.png
Diff not rendered.
Binary file removed images/160x160/286.png
Diff not rendered.
Binary file removed images/160x160/287.png
Diff not rendered.
Binary file removed images/160x160/288.png
Diff not rendered.
Binary file removed images/160x160/289.png
Diff not rendered.
Binary file removed images/160x160/29.png
Diff not rendered.
Binary file removed images/160x160/290.png
Diff not rendered.
Binary file removed images/160x160/291.png
Diff not rendered.
Binary file removed images/160x160/292.png
Diff not rendered.
Binary file removed images/160x160/293.png
Diff not rendered.
Binary file removed images/160x160/294.png
Diff not rendered.
Binary file removed images/160x160/295.png
Diff not rendered.
Binary file removed images/160x160/296.png
Diff not rendered.
Binary file removed images/160x160/297.png
Diff not rendered.
Binary file removed images/160x160/298.png
Diff not rendered.
Binary file removed images/160x160/299.png
Diff not rendered.
Binary file removed images/160x160/3.png
Diff not rendered.
Binary file removed images/160x160/30.png
Diff not rendered.
Binary file removed images/160x160/300.png
Diff not rendered.
Binary file removed images/160x160/301.png
Diff not rendered.
Binary file removed images/160x160/302.png
Diff not rendered.
Binary file removed images/160x160/303.png
Diff not rendered.
Binary file removed images/160x160/304.png
Diff not rendered.
Binary file removed images/160x160/305.png
Diff not rendered.
Binary file removed images/160x160/306.png
Diff not rendered.
Binary file removed images/160x160/307.png
Diff not rendered.
Binary file removed images/160x160/308.png
Diff not rendered.
Binary file removed images/160x160/309.png
Diff not rendered.
Binary file removed images/160x160/31.png
Diff not rendered.
Binary file removed images/160x160/310.png
Diff not rendered.
Binary file removed images/160x160/311.png
Diff not rendered.
Binary file removed images/160x160/312.png
Diff not rendered.
Binary file removed images/160x160/313.png
Diff not rendered.
Binary file removed images/160x160/314.png
Diff not rendered.
Binary file removed images/160x160/315.png
Diff not rendered.
Binary file removed images/160x160/316.png
Diff not rendered.
Binary file removed images/160x160/317.png
Diff not rendered.
Binary file removed images/160x160/318.png
Diff not rendered.
Binary file removed images/160x160/319.png
Diff not rendered.
Binary file removed images/160x160/32.png
Diff not rendered.
Binary file removed images/160x160/320.png
Diff not rendered.
Binary file removed images/160x160/321.png
Diff not rendered.
Binary file removed images/160x160/322.png
Diff not rendered.
Binary file removed images/160x160/323.png
Diff not rendered.
Binary file removed images/160x160/324.png
Diff not rendered.
Binary file removed images/160x160/325.png
Diff not rendered.
Binary file removed images/160x160/326.png
Diff not rendered.
Binary file removed images/160x160/327.png
Diff not rendered.
Binary file removed images/160x160/328.png
Diff not rendered.
Binary file removed images/160x160/329.png
Diff not rendered.
Binary file removed images/160x160/33.png
Diff not rendered.
Binary file removed images/160x160/330.png
Diff not rendered.
Binary file removed images/160x160/331.png
Diff not rendered.
Binary file removed images/160x160/332.png
Diff not rendered.
Binary file removed images/160x160/333.png
Diff not rendered.
Binary file removed images/160x160/334.png
Diff not rendered.
Binary file removed images/160x160/335.png
Diff not rendered.
Binary file removed images/160x160/336.png
Diff not rendered.
Binary file removed images/160x160/337.png
Diff not rendered.
Binary file removed images/160x160/338.png
Diff not rendered.
Binary file removed images/160x160/339.png
Diff not rendered.
Binary file removed images/160x160/34.png
Diff not rendered.
Binary file removed images/160x160/340.png
Diff not rendered.
Binary file removed images/160x160/341.png
Diff not rendered.
Binary file removed images/160x160/342.png
Diff not rendered.
Binary file removed images/160x160/343.png
Diff not rendered.
Binary file removed images/160x160/344.png
Diff not rendered.
Binary file removed images/160x160/345.png
Diff not rendered.
Binary file removed images/160x160/346.png
Diff not rendered.
Binary file removed images/160x160/347.png
Diff not rendered.
Binary file removed images/160x160/348.png
Diff not rendered.
Binary file removed images/160x160/349.png
Diff not rendered.
Binary file removed images/160x160/35.png
Diff not rendered.
Binary file removed images/160x160/350.png
Diff not rendered.
Binary file removed images/160x160/351.png
Diff not rendered.
Binary file removed images/160x160/352.png
Diff not rendered.
Binary file removed images/160x160/353.png
Diff not rendered.
Binary file removed images/160x160/354.png
Diff not rendered.
Binary file removed images/160x160/355.png
Diff not rendered.
Binary file removed images/160x160/356.png
Diff not rendered.
Binary file removed images/160x160/357.png
Diff not rendered.
Binary file removed images/160x160/358.png
Diff not rendered.
Binary file removed images/160x160/359.png
Diff not rendered.
Binary file removed images/160x160/36.png
Diff not rendered.
Binary file removed images/160x160/360.png
Diff not rendered.
Binary file removed images/160x160/361.png
Diff not rendered.
Binary file removed images/160x160/362.png
Diff not rendered.
Binary file removed images/160x160/363.png
Diff not rendered.
Binary file removed images/160x160/364.png
Diff not rendered.
Loading