透過網頁讀取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. 無法依圖層混合模式輸出圖片






解決方法:無法解決
https://doxhealthpharm.shop/# buy doxycycline without prescription
Com o codigo promocional 1XBET: GRATIS777 voce recebe bonus de boas-vindas de ate R$1200 para fazer suas apostas esportivas. Use o codigo no cadastro para liberar beneficios em grandes eventos de futebol e outras vantagens.
codigo 1xbet
where to buy cheap clomid without rx: can i get clomid without insurance – where buy cheap clomid without insurance
Resist that temptation and do all you can to gather data and have a heart-to-heart with your child to understand what happened and why,オナホ おすすめas well as the impact it has had on him or her.
it’s not the physical touch.中国 エロFor men,
Males reported declines in sexual behaviors with a partner of a different sex.リアル ドールAdolescent males reported delays in the timing of first penile-vaginal intercourse.
Because it might take longer for you or your partner to become aroused,take more time to set the stage for romance,セックス ドール
人形 エロIt works even if you currently struggle to orgasm during sex or when masturbating.You can find out more here.
these sex tips,エロ 人形advice and tactics will all tee you up for great sex.
エロ 人形sexual tension is created when your man wants something sexual,but he can’t have it,
オナホ おすすめYou can start having these conversations with your children as soon as they begin using words to talk about feelings or emotions.Don’t worry if you haven’t started conversations around these topics with your child—it is never too late.
浜哄舰 銈ㄣ儹The government recommends drinking 6 to 8 glasses every day.This is in addition to the fluid you get from the food you eat.
“People with sexual dysfunction might not want a sexual partner to touch their genitals,but mindfulness gives us the ability to a have full-body connection and possibly full-body orgasms,リアル ドール
We find that the strongest predictors of early involvement in sexual activity include (1) academic achievement and (2) attitudes toward sex.リアル ドールFor academic achievement,
ラブドール えろCurrent data suggest that slightly more than half of females and nearly two-thirds of males have had intercourse by their 18th birthday.In the last several decades there have been substantial increases in the proportion of adolescents who report sexual activity at each year of age.
オナホ おすすめthere may be concerns by parents and clinicians if the following become evident:painful menstruationchronic pelvic painpartial vaginal outflow obstruction/imperforate hymenpossible anatomical defectsViews on sexual activityOne study from 1996 documented the interviews of a sample of junior high school students in the United States.The girls were less likely to state that they ever had sex than adolescent boys.
not feeling judged.Molly Kuehl:We have fun together.中国 エロ
浜哄舰 銈ㄣ儹increased production of processed foods,rapid urbanization and changing lifestyles have led to a shift in dietary patterns.
we need to work with our youth to assure that peer norms support them in making the best choices and encouraging accountability.オナホTo counter the influences of hypersexualized media and the all too easy access to pornography,
人形 エロThe older women are,she adds,
many people share some of the most common fantasies.When sex researcher Dr.エロ 人形
エロ 人形“That way,you can approach your next sexual connection with new synergy and curiosity.
エロ 人形A story about dominating your man.A story about both of you,
where can i buy doxycycline capsules: DoxHealthPharm – how to get doxycycline online
https://doxhealthpharm.com/# doxycycline purchase
エロ 人形7 Ways to Improve Your Sex Life Practice,practice,
http://zithropharm.com/# zithromax cost canada
And then just natural menopause.中国 エロAgain,
amoxicillin discount Amo Health Pharm buy amoxicillin over the counter uk
エロ 人形they want the acceptance,they want to feel wanted by their partner,