About this workshop
Pikkola, tool No. 15
A file is a drawing plus the history of the editor that made it. Only one of those has to ship.
The file is heavier than the picture
Export an icon from a design tool and open it in a text editor. Around the path there is a licence block, a page colour, a zoom level, three namespace declarations and coordinates with nine decimal places. None of it draws anything.
The optimisers we tried either wanted the file uploaded first or rewrote the geometry. A confidential icon set should not need a third party, and a logo should not come back with different curves.
What the cleaner touches
Comments, the metadata block, editor namespaces (Inkscape, Sodipodi, Adobe, Serif), empty groups, width and height when a viewBox already scales the drawing, indentation and decimal places beyond two. Each rule can be switched off, and the report names every rule that removed something.
Ids stay. So do title and desc, SMIL animation, CSS in a style element and embedded scripts. Those change what the file does rather than how it is stored, and this page is not willing to guess about behaviour.
How the preview and the PNG are made
The cleaned text becomes a blob and the browser draws it in an image element on a checkerboard. Zoom is a CSS size on that image, so what you see is the browser's own rendering of the cleaned file.
For a PNG the same blob is drawn into a canvas at the size you chose and taken out with toBlob. A web font called by name is not in the file, so it will not render; outline the text or embed the font.
The component output
React gets a function component: attribute names in JSX spelling, class as className, a style string as a style object, namespaced attributes such as xlink:href as xlinkHref. Props are spread first so the drawing's own attributes win.
Vue gets a single file component with the markup in the template and any style element moved into a scoped block. Neither output invents props, wraps the drawing in a design system or asks for a build step before it can be read.
What it will not do
It does not simplify paths, merge shapes or rewrite geometry. Those are design decisions, and a tool that makes them quietly is how a curve changes between versions.
It does not audit embedded scripts. If you clean a file from elsewhere, read it before you ship it.
It does not embed fonts, and it does not guarantee that a preview matches every renderer. Test the file where it will be used.
If something is wrong
Write to hello@pikkola.com with the file and the rule that behaved unexpectedly. A small sample is worth more than a description.
Back to the studio
이 작업장에 대해
피콜라, 15호기
파일은 그림에 그것을 만든 편집기의 이력을 더한 것입니다. 배에 실어야 하는 것은 하나뿐입니다.
파일이 그림보다 무겁다
디자인 도구에서 아이콘을 내보내 텍스트 편집기로 열어 보세요. 패스 옆에 라이선스 블록, 페이지 색, 확대율, 네임스페이스 선언 세 개, 소수점 아홉 자리 좌표가 붙어 있습니다. 그중 어느 것도 그림을 그리지 않습니다.
우리가 써 본 최적화 도구는 파일을 먼저 올리게 하거나 도형을 다시 그렸습니다. 기밀 아이콘 세트에 제3자가 필요할 이유는 없고, 로고가 다른 곡선으로 돌아올 이유도 없습니다.
정리기가 건드리는 것
주석, 메타데이터 블록, 편집기 네임스페이스(잉크스케이프, 소디포디, 어도비, 세리프), 빈 그룹, viewBox가 이미 크기를 정할 때의 width와 height, 들여쓰기, 소수점 두 자리를 넘는 자릿수. 규칙마다 끌 수 있고, 보고서가 어떤 규칙이 무엇을 지웠는지 이름으로 보여 줍니다.
id는 남깁니다. title과 desc, SMIL 애니메이션, style 요소 안의 CSS, 파일에 든 스크립트도 남깁니다. 그것들은 저장 방식이 아니라 동작을 바꾸고, 이 페이지는 동작을 짐작하지 않습니다.
미리보기와 PNG를 만드는 방식
정리한 텍스트를 blob으로 만들어 브라우저가 이미지 요소로 체커보드 위에 그립니다. 확대는 그 이미지의 CSS 크기라, 보이는 것은 브라우저가 정리된 파일을 그린 결과 그대로입니다.
PNG는 같은 blob을 고른 크기의 캔버스에 그리고 toBlob으로 꺼냅니다. 이름으로 부르는 웹 폰트는 파일 안에 없으므로 그려지지 않습니다. 글자를 외곽선으로 바꾸거나 폰트를 넣으세요.
컴포넌트 출력
React에는 함수 컴포넌트로 갑니다. 속성 이름은 JSX 표기, class는 className, style 문자열은 객체, xlink:href 같은 네임스페이스 속성은 xlinkHref가 됩니다. props를 먼저 펼쳐 그림 자체의 속성이 이기게 합니다.
Vue에는 템플릿에 마크업을 넣고 style 요소가 있으면 scoped 블록으로 옮긴 단일 파일 컴포넌트로 갑니다. 어느 쪽도 없는 props를 지어내지 않고, 그림을 디자인 시스템으로 감싸지 않으며, 읽기 전에 빌드를 요구하지 않습니다.
하지 않는 일
패스를 단순화하거나 도형을 합치거나 좌표를 다시 쓰지 않습니다. 그런 것은 디자인 결정이고, 조용히 해 주는 도구가 버전 사이에서 곡선을 바꾸는 방식입니다.
파일에 든 스크립트를 검사하지 않습니다. 다른 곳에서 받은 파일을 정리한다면 배에 싣기 전에 읽어 보세요.
폰트를 넣지 않고, 미리보기가 모든 렌더러와 같다고 보증하지도 않습니다. 쓸 곳에서 파일을 시험해 보세요.
뭔가 잘못됐다면
파일과 이상하게 동작한 규칙을 hello@pikkola.com으로 보내 주세요. 작은 예시 하나가 설명보다 낫습니다.
스튜디오로 돌아가기
この作業場について
Pikkola、15号機
ファイルは絵に、それを作った編集ソフトの履歴を足したものです。積むべきなのは片方だけです。
ファイルは絵より重い
デザインソフトからアイコンを書き出してテキストエディタで開いてみてください。パスのまわりにライセンスのブロック、ページの色、拡大率、3つの名前空間の宣言、小数点以下9桁の座標が付いています。どれも絵を描きません。
試した最適化は、ファイルを先に上げさせるか、図形を書き直しました。機密のアイコン一式に第三者が必要な理由はなく、ロゴが違う曲線で戻ってくる理由もありません。
整理が触るもの
コメント、メタデータのブロック、編集ソフトの名前空間(Inkscape、Sodipodi、Adobe、Serif)、空のグループ、viewBoxがすでに大きさを決めているときのwidthとheight、インデント、小数2桁を超える桁。ルールごとに切ることができ、報告がどのルールが何を消したかを名前で示します。
idは残します。titleとdesc、SMILアニメーション、style要素の中のCSS、ファイルに入ったスクリプトも残します。それらは保存の形ではなく動きを変えるもので、このページは動きを推測しません。
プレビューとPNGの作り方
整理したテキストをblobにして、ブラウザが画像要素としてチェッカーボードの上に描きます。拡大はその画像のCSSの大きさなので、見えているのはブラウザが整理後のファイルを描いた結果そのものです。
PNGは同じblobを選んだ大きさのキャンバスに描き、toBlobで取り出します。名前で呼ぶWebフォントはファイルの中にないので描かれません。文字をアウトライン化するか、フォントを埋め込んでください。
コンポーネントの出力
Reactには関数コンポーネントで渡します。属性名はJSXの書き方、classはclassName、style文字列はオブジェクト、xlink:hrefのような名前空間付きの属性はxlinkHrefになります。propsを先に展開し、絵自身の属性が勝つようにします。
Vueにはテンプレートにマークアップを入れ、style要素があればscopedブロックに移した単一ファイルコンポーネントで渡します。どちらもないpropsを作らず、絵をデザインシステムで包まず、読む前にビルドを求めません。
しないこと
パスを単純化したり、図形を統合したり、座標を書き直したりしません。それはデザインの判断で、黙ってやってくれる道具は、版の間で曲線を変えてしまうやり方です。
ファイルに入ったスクリプトを検査しません。他所から受け取ったファイルを整理するなら、積む前に読んでください。
フォントを埋め込まず、プレビューがすべての描画系と一致すると保証もしません。使う場所でファイルを試してください。
何かおかしいとき
ファイルと、思ったとおりに動かなかったルールを hello@pikkola.com まで。小さな例ひとつのほうが説明より役立ちます。
スタジオへ戻る