透過網頁讀取Photoshop PSD檔案內容
在專案中有需要透過網頁來讀取Photoshop PSD檔案的內部資訊,我們透過PSD.js(備用載點)來實現這樣的功能,在官方提供的功能展示頁中,我們可以看到在頁面中只需引入psd.min.js後,加入透過少量的Javascript就可以針對PSD進行解析。
<!DOCTYPE html> <html> <head> <title>psd.js image example</title> <style type="text/css"> body, html { padding: 0; margin: 0; } #dropzone { width: 500px; height: 100px; border: 1px #ababab dashed; margin: 50px auto; } #dropzone p { text-align: center; line-height: 100px; margin: 0; padding: 0; } #image { text-align: center; } </style> <script type="text/javascript" src="psd.min.js"></script> </head> <body> <div id="dropzone"> <p>Drop here</p> </div> <div id="image"></div> <pre id="data"></pre> <script type="text/javascript"> (function () { var PSD = require('psd'); document.getElementById('dropzone').addEventListener('dragover', onDragOver, true); document.getElementById('dropzone').addEventListener('drop', onDrop, true); function onDragOver(e) { e.stopPropagation(); e.preventDefault(); e.dataTransfer.dropEffect = 'copy'; } function onDrop(e) { e.stopPropagation(); e.preventDefault(); PSD.fromEvent(e).then(function (psd) { var data = JSON.stringify(psd.tree().export(), undefined, 2); document.getElementById('data').innerHTML = data; document.getElementById('image').appendChild(psd.image.toPng()); }); } }()); </script> </body> </html>
我們透過下圖這樣的一個PSD檔案對頁面進行測試,檔案中共有三個圖層,包含一個文字圖層。
頁面將PSD分析出結果後,以json格式顯示在頁面上,可以看到文字圖層的部分,不僅能讀到圖層名稱也包含文字內容和字型名稱。
{ "children": [ { "type": "layer", "visible": true, "opacity": 1, "blendingMode": "normal", "name": "Photoshop Text", "left": 302, "right": 723, "top": 90, "bottom": 128, "height": 38, "width": 421, "mask": {}, "text": { "value": "THIS IS TEXT LAYER", "font": { "name": "MyriadPro-Regular\u0000", "sizes": [ 53 ], "colors": [ [ 0, 0, 0, 255 ] ], "alignment": [ "center" ] }, "left": 0, "top": 0, "right": 0, "bottom": 0, "transform": { "xx": 1, "xy": 0, "yx": 0, "yy": 1, "tx": 513, "ty": 127 } }, "image": {} }, { "type": "layer", "visible": true, "opacity": 1, "blendingMode": "normal", "name": "PSD Icon", "left": 287, "right": 738, "top": 209, "bottom": 669, "height": 460, "width": 451, "mask": {}, "image": {} }, { "type": "layer", "visible": true, "opacity": 1, "blendingMode": "normal", "name": "Background", "left": 0, "right": 1024, "top": 0, "bottom": 800, "height": 800, "width": 1024, "mask": {}, "image": {} } ], "document": { "width": 1024, "height": 800, "resources": { "layerComps": [], "guides": [], "slices": [] } } }
bs2web nl – рабочая ссылка на blacksprut, блекспрут зеркало
частная скорая наркологическая помощь [url=https://ivanovo.forum24.ru/?1-15-0-00000582-000-0-0-1730876715/]частная скорая наркологическая помощь[/url] .
загранпаспорт быстро [url=http://www.airlady.forum24.ru/?1-9-0-00000223-000-0-0-1735287116]загранпаспорт быстро[/url] .
Generic Cialis price: Tadalafil Tablet – Cialis over the counter
наркологическая срочная помощь наркологическая срочная помощь .
загранпаспорт срочно москва [url=https://guryevsk.forum24.ru/?1-4-0-00000570-000-0-0-1735286442/]https://guryevsk.forum24.ru/?1-4-0-00000570-000-0-0-1735286442/[/url] .
https://maxpillsformen.com/# cialis for sale
скорая наркологическая помощь в москве скорая наркологическая помощь в москве .
наркологическая скорая бесплатная https://vishivayu.ukrbb.net/viewtopic.php?f=12&t=13503/ .
наркологическая скорая в москве наркологическая скорая в москве .
buy ed meds: ed meds cheap – erectile dysfunction meds online
срочная наркологическая помощь в москве [url=taksafonchik.borda.ru/?1-2-0-00001312-000-0-0-1730876668]срочная наркологическая помощь в москве[/url] .
частная скорая наркологическая помощь [url=www.golosa.ukrbb.net/viewtopic.php?f=3&t=7485/]частная скорая наркологическая помощь[/url] .
как вызвать наркологическую скорую помощь в москве [url=www.gov.ukrbb.net/viewtopic.php?f=3&t=6398/]как вызвать наркологическую скорую помощь в москве[/url] .
срочная наркологическая помощь [url=www.honey.ukrbb.net/viewtopic.php?f=45&t=16764/]срочная наркологическая помощь[/url] .
Also visit my page … Melvina
cheapest cialis: Cialis 20mg price – Cialis 20mg price in USA
срочная наркологическая помощь срочная наркологическая помощь .
срочная наркологическая помощь в москве срочная наркологическая помощь в москве .
частная скорая наркологическая помощь http://www.klin.0pk.me/viewtopic.php?id=4428 .
Witamy w Slotico! Tutaj znajdziesz unikalną kolekcję kasyn online. Slottica PL oferuje setki gier, od klasycznych automatów do gier po nowoczesne automaty wideo i ekscytujące gry stickman na żywo.
Also visit my blog; Daycare Near Me – Find The Best Daycares Near You
https://maxpillsformen.com/# cheapest cialis
THANK YOU! ENJOY YOUR 20% OFF ONE TIME USE CODE: EMAILSIGNUP20 Virtual hug happening. Green Aventurine Gua Sha – Jade Gua Sha To enable personalized advertising (like interest-based ads), we may share your data with our marketing and advertising partners using cookies and other technologies. Those partners may have their own information they’ve collected about you. Turning off the personalized advertising setting won’t stop you from seeing Etsy ads or impact Etsy’s own personalization technologies, but it may make the ads you see less relevant or more repetitive. JOIN THE TRIBE FOR EXCLUSIVE OFFERS, NEW LAUNCHES & TIPS FROM OUR TRIBE I purchased the Rose Quartz Gua Sha and it has become my favorite part of my skincare and wellness routine. It is beautifully made and I like that it comes with its own storage bag which is great for traveling. My humble advice to everyone is to be gentle and to handle this stone with a lot of love and care as I feel it could potentially break if dropped. But I’m very excited to learn more about the tool and overall I’m VERY happy with my purchase!
https://wiki-saloon.win/index.php?title=Using_eye_cream_as_moisturizer
Customer review: “I swear by this eyeliner!! I’m on my third pot now and have no intention of trying any other gel eyeliner. This eyeliner is so incredibly easy to apply. It does not smudge whatsoever even throughout an 8 hour shift.” — Sephora Eye Defining Pen Liquid Eyeliner Duo What Else You Need to Know: Just one swipe of this gel-ink formula gives intense, long-lasting color in satin or metallic finishes. Ultra-precise felt-tip applies waterproof color smoothly. No pulling, skipping, or tugging on eyelids. Used backstage at many top runway shows, this inky and super-black liquid liner is best wielded by someone who is a skilled liner enthusiast. It’s a little too liquid for beginners. And they all survived a heat wave. Swipe bestselling Tattoo Liner Collection hi-viz liquid + pencil looks that last.
http://fastpillsformen.com/# Cheap generic Viagra online
можно ли купить диплом о высшем образовании можно ли купить диплом о высшем образовании .
hop over to this web-site https://my-sollet.com
загранпаспорт срочно москва загранпаспорт срочно москва .
наркологическая срочная помощь наркологическая срочная помощь .
скорая наркологическая помощь в москве скорая наркологическая помощь в москве .