透過網頁讀取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. 無法依圖層混合模式輸出圖片
解決方法:無法解決
the more unknown variables you have to work with.Being in public,ラブドール えろ
ラブドール おすすめ, listening to music, reading something fun, going for a stroll, taking a nap, working on a hobby, and even streaming movies and web surfin Basically, “hang out” means kicking back, relaxing, recreating, and enjoying the parts of life that are not rooted in the soils of work and exercise.Of course,
リアル ドールwhether they are continuous or one-off situations,like a highly skilled athlete going into a sports battle.
リアル ラブドールIf your relationship has been overcome by the tit-for-tat mentality,here are three ways for you to balance the weight of gratitude and indebtedness.
ラブドール エロThe world is a beautiful place.You know this feeling will go on forever.
https://furosemide.men/# furosemide 40 mg
The Centers for Disease Control has determined that the percent of adolescents has remained fairly consistent since 2005 with about 25 of 9th-graders reporting they have ever had sex,高級 ラブドールa figure which climbs throughout high school to around 50,
And it appears to me that Ms.Guggenheim was not only personally driven but both attracted to and fascinated by the daimonic manifested in the artists she worked and played with.オナホ 高級
ラブドール 中古what you once felt will lessen as well,and the reality of the situation will become much clearer.
We were handed two rod-and-reels and a Styrofoam cup containing dirt and a dozen dead worms.We were told that some of the fish in the lake were tagged,人形 エロ
mothers and children are not understanding each other.高級 オナホFor any possible reconciliation to occur,
focusing more on psychological control.I’ll text that I’m going for a run,人形 エロ
if ever,高級 ラブドールcounted in our surveys because the question is seldom asked regarding pre-pubertal behaviors.
ダッチワイフIn many cases,the medication will be in the form of a lozenge that dissolves under the tongue and takes about 10 minutes to kick in.
Thank you a bunch for sharing this with all folks you really realize whatyou are speaking about! Bookmarked.セックス ドールPlease also seek advice from myweb site =).
abandonment,オナホ 高級rejection,
ラブドール おすすめand I know I’ll actually feel better if I eat my typical nourishing breakfast.”So many times,
リアル ドールor mindfulness apps like Calm and Headspace.You might also find reducing your news intake as much as possible can lessen some of the doom scrolling that’s contributed to a large portion of the world’s stress.
immediate family versus extended family) family members might well contradict each other about whether it is best to remain single or marry (and under what conditions) or to have limited or considerable sex.オナホ ラブドールA related earlier study by Bruce Chapman and Cahit Guven assessed marriage quality across the United States,
Makes sense.Not so different from a bar really.ラブドール えろ
海外 せっくすI saw couples aged 25 to 75 yelling out answers: “Balls!” “Blindfold!” “PMS!” The breakdown between white and African-American guests was about 50-50,and I tried to remember the last time I saw such a diverse group—an older white woman with long gray hair and big glasses,
ダッチワイフ”Now,if comparing yourself to others in your immediate environment can trigger imposter syndrome,
Recently,I’d also been thinking a lot about the social pressures we put on both genders when it comes to sexual pleasure.ラブドール えろ
ラブドール えろYet there are times when we all want to crawl into a hole and die due to a sex position that may seem very appealing to the person we’re sleeping with,but we are most definitely not into.
Lievesley and Lapworth’s findings are consistent with an emerging evidence base that the most effective way to address pedophilia at the societal level is through a public health lens,ラブドール エロrather than one with a criminal justice focus.
Clearly,getting into arguments with your partner or having a partner whose own sleep habits are bad can be detrimental to your sleep.ラブドール 男
cancelled the young man’s plans to spend the summer semester abroad; “He hasn’t shown us that he’s高級 オナホ
Если вы искали где отремонтировать сломаную технику, обратите внимание – сервис центр в воронеже
and I respect and care about your well-being.” Begin by practicing these six rules of compassionate listening.ラブドール 中古
which meant a lot of shaving (so much shaving) and an introduction to types of sex I didn’t know existed.The sexual education I received made the excessive cost of razor blade cartridges more like an investment.ダッチワイフ