透過網頁讀取PSD後,依圖層輸出PNG檔案
在前面介紹過網頁可以讀取PSD檔案並擷取到該檔案的資訊,接著我們會希望能透過網頁上傳PSD檔之後,依照圖層來輸出圖片,同樣是利用PSD.js來輔助進行,可以透過我們製作的範例頁面來進行輸出測試。
預設輸出效果
透過PSD.js可將PSD內的各圖層輸出成PNG圖檔,亦可轉成Base 64圖檔格式,惟輸出時每個圖檔的尺寸並不會根據整體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 PSD here</p> </div> <div id="image"></div> <pre id="data"></pre> <script type="text/javascript"> (function () { const 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) { for (var i = 0; i < psd.layers.length; i ++){ document.getElementById('image').appendChild(psd.layers[i].image.toPng()); } }); } }()); </script> </body> </html>
依照整體PSD配置進行輸出
我們希望讓每個圖片在輸出後能保時相同的尺寸,也就是依照PSD的畫布大小來輸出每一張圖檔,但在原生PSD.js中並不具備這樣的功能,於是我們透過下述的方式來達成:
- 擷取PSD資訊並將圖檔轉為Base 64格式
- 產生與PSD尺寸大小相同的HTML Canvas
- 將產生的Base 64圖檔,依照原始位置放入Canvas中
- 將Canvas轉成PNG圖檔




可以參考我們製作的範例頁面
<!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 PSD here</p> </div> <div id="image"></div> <pre id="data"></pre> <script type="text/javascript"> (function () { const 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) { const PSDWidth = psd.tree().width; const PSDHeight = psd.tree().height; for (var i = 0; i < psd.layers.length; i ++){ const img = new Image(); img.src = psd.layers[i].image.toBase64(); console.log(psd); const layerWidth = psd.layers[i].width; const layerHeight = psd.layers[i].height; const layerLeft = psd.layers[i].left; const layerTop = psd.layers[i].top; const canvas = document.createElement("canvas"); canvas.setAttribute('class', "canvas"); canvas.width = PSDWidth; canvas.height = PSDHeight; console.log("canvas :", canvas); img.onload = function(){ canvas.getContext("2d").drawImage(img, layerLeft, layerTop, layerWidth, layerHeight); document.getElementById('image').appendChild(canvas); } } }); } }()); </script> </body> </html>
PSD檔案輸出限制
1. 無法輸出帶有效果的圖片
在PSD中我們可能會針對圖層套用一些效果,例如:陰影、光暈、筆畫…等等,但在輸出後的圖檔將不會帶有這些效果。



解決方法:透過點陣化圖層效果,即可輸出相對應的圖檔。
2. 無法輸出帶有遮色片效果的圖片



解決方法:將圖層轉為智慧型物件,即可輸出相對應的圖檔。
3. 無法依圖層混合模式輸出圖片






解決方法:無法解決
пин ап казино зеркало – пин ап казино официальный сайт
buy viagra
пин ап – пин ап вход
пин ап казино официальный сайт – пин ап зеркало
пинап казино – пин ап вход
пин ап казино зеркало – пин ап казино
pinup 2025 – пин ап казино
Eric Mortensen is an owner and head writer on Geeky Hobbies since 2014. He is an avid board game player and collector with over 3,000 board and card games in his collection. Since 2014 he has written more than 1,100 board game how to play guides. We are not liable for any issues or disruptions users may encounter when accessing the linked casino websites. Please report any problem to the respective casino’s support team. The house edge is a term that describes the casino’s advantage over the player in any casino game. In Hi Lo, the house edge can vary depending on the specific variation and the online casino. Generally, the house edge for Hi Lo ranges from 2.5% to 5%. Any winnings are contributed to the chips on the table for reuse in subsequent rounds. Ending the current game session is accomplished by amassing all winnings.
http://dayawane.ihep.ac.cn/twiki/bin/view/Public/JamesReynolds
info@dougruckerstore State-of-the-art Bombardier Global 7500’s are now available within the U.S. Book through XO with no ownership or long-term commitment required. Operated throughout North America by Vista America, Global 7500s offer the ultimate combination of range, speed, and comfort. The wide area output flow creates a uniform counter current around the entire body, just like a wave in the ocean. The free paver sealing class hosted by Surface Logix is this Wednesday, April 5th at 11a.m. Remember if you’re coming in a group carpool, and Please NO TRAILERS space is extremely limited. Thank you! Dismiss Explore related questions Thursday – 7am – 3pm Due to the modular design of the counter current system, it is possible to have different flows of 1085 – 4000 l min or 65 – 240 m³ h, depending on the desired intensity of the jet.
1win sports betting https://1win12.com.ng .
I’m gone to tell my little brother, that he should also pay a quick visit this web site
on regular basis to take updated from most up-to-date news.
1хwin https://www.admiralshow.forum24.ru/?1-17-0-00000242-000-0-0-1742816555 .
пин ап зеркало – пин ап вход
пин ап вход – пин ап казино зеркало
تاریخ برگزاری کنکور سراسری، بر
اساس اعلام سازمان سنجش آموزش کشور، تاریخ دقیق
برگزاری کنکور سراسری سال ۱۴۰۴ در تمامی گروههای آزمایشی
ریاضی، تجربی، انسانی، هنر و زبان، در دو نوبت مجزا در سال برگزار خواهد شد.
пин ап казино: https://pinupkz.life/
пин ап казино официальный сайт: https://pinupkz.life/
I have been surfing online more than 3 hours today, yet I never found any interesting
article like yours. It’s pretty worth enough for me.
In my view, if all web owners and bloggers made good content as you
did, the net will be a lot more useful than ever before.
пин ап казино официальный сайт – пин ап казино
I am extremely inspired with your writing skills as smartly as with
the structure for your weblog. Is this a paid subject or did you
modify it your self? Anyway keep up the nice quality
writing, it is rare to see a nice blog like this one these days..
*The terms and conditions hereby govern Hilo’s Recommendation Program. Please read them carefully to find out about the eligibility requirements for a Referrer and Invitee Hilo customers, as well as the terms and conditions for obtaining bonuses and discounts. hiloenergie en-ca our-offer *Quebec only* Until May 26th18, take advantage of a 15% discount applied towards the total amount of your shopping cart before taxes, with no minimum purchase, when subscribing to Hilo’s smart home service, which requires a commitment to participate in Hilo … Hawaii Printing Corporation has 50 years’ experience designing and manufacturing quality promotional products that truly attract attention. There’s really no better way to advertise your business or brand. Our promotional product company is ready to help you get your name out there with outstanding products, permanent signs, lettering, and more – contact us at 808-961-6651 to learn more!
http://joffsecphitas1970.raidersfanteamshop.com/https-gamecs-net
People love the Mine Island game because it’s artistically appealing and easy to use. The graphics are meant to be bright and colourful, and the bright colours and fine details make the scene look like a tropical island. When players enter Mine Island, they must first select their bet size using the “minus” and “plus” controls at the bottom of the screen. Breed your Monsters to create charming new species. With so many singing Monsters to collect and more Monsters added all the time, you’ll never run out of quirky characters. To create a private server in Minecraft APK, you can use third-party Minecraft server applications or services. Through these apps, you can customize your server settings and invite friends to join. Although the idea of hacking Mines may seem appealing, it is crucial to be aware of the risks involved. As hacking mines can have serious consequences:
пин ап казино зеркало: https://pinupkz.life/
Профессиональный сервисный центр по ремонту бытовой техники с выездом на дом.
Мы предлагаем:ремонт бытовой техники в мск
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
пин ап зеркало: https://pinupkz.life/
I absolutely love your blog and find the majority
of your post’s to be exactly what I’m looking for.
Do you offer guest writers to write content for you?
I wouldn’t mind writing a post or elaborating on many
of the subjects you write regarding here. Again, awesome website!
pinup 2025 – пин ап вход
пин ап – пин ап казино
My partner and I stumbled over here by a different page and thought I might as well
check things out. I like what I see so i am just following you.
Look forward to finding out about your web page yet
again.
Профессиональный сервисный центр по ремонту бытовой техники с выездом на дом.
Мы предлагаем:ремонт бытовой техники в мск
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
Профессиональный сервисный центр по ремонту бытовой техники с выездом на дом.
Мы предлагаем:сервисные центры в москве
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
пин ап казино официальный сайт – пин ап казино официальный сайт