透過網頁讀取PSD後,依圖層輸出PNG檔案
在前面介紹過網頁可以讀取PSD檔案並擷取到該檔案的資訊,接著我們會希望能透過網頁上傳PSD檔之後,依照圖層來輸出圖片,同樣是利用PSD.js來輔助進行,可以透過我們製作的範例頁面來進行輸出測試。
預設輸出效果
透過PSD.js可將PSD內的各圖層輸出成PNG圖檔,亦可轉成Base 64圖檔格式,惟輸出時每個圖檔的尺寸並不會根據整體PSD檔大小來配置。
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/layout4.png)
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/layer1.png)
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/2-1.png)
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/3-1.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) { 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圖檔
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/layout4.png)
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/1-1.png)
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/2-2.png)
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/3-1.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中我們可能會針對圖層套用一些效果,例如:陰影、光暈、筆畫…等等,但在輸出後的圖檔將不會帶有這些效果。
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/layer-1.png)
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/before-1-320x320-1.png)
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/unnamed-file.png)
解決方法:透過點陣化圖層效果,即可輸出相對應的圖檔。
2. 無法輸出帶有遮色片效果的圖片
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/layer2.png)
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/before1-1.png)
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/unnamed-file.png)
解決方法:將圖層轉為智慧型物件,即可輸出相對應的圖檔。
3. 無法依圖層混合模式輸出圖片
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/layer3.png)
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/before2.png)
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/1-320x320-1.png)
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/layer1-1.png)
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/2-1-1.png)
![](https://cloudlab.tw/wp/wp-content/uploads/2020/04/3-1.png)
解決方法:無法解決
cheapest pharmacy prescription drugs https://xxlmexicanpharm.shop/# mexico drug stores pharmacies
buy furosemide pills – piracetam brand order betnovate 20 gm for sale
canada drugs coupon code https://discountdrugmart.pro/# drugmart
안녕하세요.오늘도 좋은하루되세요.언제나 행복한 하루세요
prescription drugs from canada http://familypharmacy.company/# Best online pharmacy
discount drug pharmacy: drug mart – drugmart
Transforme suas apostas com a [bwin](https://bwin-br.com)! Faça seu cadastro em minutos, ganhe um bônus exclusivo para novos usuários e aproveite todas as vantagens. Após criar sua conta, basta fazer login para explorar jogos emocionantes, apostas esportivas e promoções que vão fazer a diferença na sua diversão.
강남가라오케
cheapest pharmacy for prescriptions https://xxlmexicanpharm.com/# п»їbest mexican online pharmacies
cheapest pharmacy prescription drugs https://familypharmacy.company/# Cheapest online pharmacy
안녕하세요.오늘도 좋은하루되세요.언제나 행복한 하루세요
mail order prescription drugs from canada https://xxlmexicanpharm.shop/# xxl mexican pharm
The Top Local Locksmith Near Me Experts Have Been Doing
3 Things local Locksmiths
mail order pharmacy no prescription https://familypharmacy.company/# Online pharmacy USA
cheapest pharmacy to fill prescriptions without insurance https://familypharmacy.company/# Online pharmacy USA
Do You Think Door Fitters Milton Keynes Never Rule The World?
Door Milton Keynes
Aerodrome Finance: Unlocking Potential for Growth
The world of aerodrome finance is pivotal for ensuring the efficient operation, enhancement, and expansion of aerodrome facilities globally. With the increasing demand for air travel, understanding aerodrome financial processes is more important than ever.
aerodrome finance
Why Aerodrome Finance Matters
Aerodrome finance plays a critical role in the lifespan of airport projects, providing necessary funding from initial development to ongoing management. Here are key reasons why it matters:
Infrastructure Development: Secure financial backing enables the construction and maintenance of essential airport infrastructure.
Operational Efficiency: Adequate funding ensures that airports can operate smoothly, adapting to technological advancements and logistical demands.
Economic Growth: Airports serve as economic hubs; their development stimulates job creation and boosts local economies.
Aerodrome Finance Strategies
Various strategies can be employed to optimize aerodrome finance, ensuring both immediate and long-term benefits. Here are a few notable approaches:
Public-Private Partnerships (PPP)
These partnerships combine public sector oversight and private sector efficiency, leading to shared risks and rewards. They facilitate diverse financial resources and innovative solutions for airport projects.
Revenue Diversification
Exploring non-aeronautical revenue streams, such as retail concessions and property leases, can significantly bolster an airport’s financial resilience. Such diversification allows for a steady income flow independent of ticket sales.
Sustainable Financing
Adopting sustainable financial practices, including green bonds and ESG (Environmental, Social, and Governance) criteria, aligns with modern ecological standards and attracts environmentally conscious investors.
Challenges and Opportunities
While aerodrome finance offers numerous benefits, it also poses certain challenges. High capital costs, regulatory hurdles, and fluctuating passenger demands can impact financial stability. However, these challenges also present opportunities for innovation and improvement.
Tech-Driven Solutions: Embracing technology like AI and predictive analytics can enhance decision-making and financial planning.
Collaboration: Strengthening ties with stakeholders, including airlines and government agencies, can streamline financial operations and capital investments.
Ultimately, the goal of aerodrome finance is to support the sustainable growth and modernization of airports, ensuring their pivotal role in global connectivity remains strong.
canada online pharmacy no prescription https://discountdrugmart.pro/# drug mart
buying from online mexican pharmacy purple pharmacy mexico price list mexican pharmaceuticals online
legal online pharmacy coupon code http://familypharmacy.company/# online pharmacy delivery usa
A brief history of sunglasses, from Ancient Rome to Hollywood
kraken даркнет
Sunglasses, or dark glasses, have always guarded against strong sunlight, but is there more to “shades” than we think?
The pupils of our eyes are delicate and react immediately to strong lights. Protecting them against light — even the brilliance reflected off snow — is important for everyone. Himalayan mountaineers wear goggles for this exact purpose.
Protection is partly the function of sunglasses. But dark or colored lens glasses have become fashion accessories and personal signature items. Think of the vast and famous collector of sunglasses Elton John, with his pink lensed heart-shaped extravaganzas and many others.
When did this interest in protecting the eyes begin, and at what point did dark glasses become a social statement as well as physical protection?
The Roman Emperor Nero is reported as holding polished gemstones to his eyes for sun protection as he watched fighting gladiators.
We know Canadian far north Copper Inuit and Alaskan Yupik wore snow goggles of many kinds made of antlers or whalebone and with tiny horizontal slits. Wearers looked through these and they were protected against the snow’s brilliant light when hunting. At the same time the very narrow eye holes helped them to focus on their prey.
In 12th-century China, judges wore sunglasses with smoked quartz lenses to hide their facial expressions — perhaps to retain their dignity or not convey emotions.
About us
Since its founding in 2020, EtherCode Innovation has demonstrated an outstanding level of expertise in smart contract development on the Ethereum platform. The EtherCode Innovation team brings together experienced developers whose knowledge and skills allow them to create reliable and innovative solutions for their clients
honeypot code
Mission
We strive to ensure that every person interested in blockchain technologies can gain high-quality knowledge and skills. Our mission is to develop smart contracts that not only improve the functionality of the Ethereum network, but also contribute to the education and development of the developer community.
Our services
EtherCode Innovation specializes in creating various smart contracts within Ethereum. We develop innovative solutions for financial instruments, decentralized applications (DApps) and digital asset management systems. Our team has deep knowledge of the Solidity and Vyper programming languages, which allows us to create secure and efficient smart contracts.
In addition, we provide free educational content for those who want to learn how to create tokens, including Honeypot tokens. Our materials cover all aspects of creating and deploying tokens on Ethereum, from basic concepts to complex technical details.
Our contribution to the community
We believe that education plays a key role in the development of the blockchain community. Therefore, we actively participate in various educational and communication initiatives. We also support various educational projects aimed at spreading knowledge about blockchain.
Development prospects
We are confident that blockchain technology will continue to transform the world, and we are committed to staying at the center of this process. Our team will continue to create innovative products, develop educational resources, and actively participate in the development of the Ethereum developer community.
Finally, it is worth noting that EtherCode Innovation is committed to continuous development and innovation. The team is constantly researching new technologies and development methods to provide its clients with the most advanced solutions. Thanks to this approach, the company remains ahead of its time and continues to be in demand in the field of blockchain development.
EtherCode Innovation is not just a company developing smart contracts on Ethereum. We are leaders in blockchain technology and education, and we invite you to join us on this exciting journey into the world of decentralization and innovation.
11 “Faux Pas” That Are Actually OK To Make With Your 2 In 1 Pram 2 In 1 pram Pushchair
Entre na emoção do mundo das apostas online com a [20 bet](https://20-bet-88.com)! Ao se registrar como novo usuário, você recebe um bônus de boas-vindas de US$ 100 para começar suas jogadas com mais vantagens. Aproveite esta oferta especial e explore diversas opções de apostas esportivas e jogos de cassino de alta qualidade.
You’ve done a fantastic job of breaking down this topic, like unlocking a door to a secret garden. Intrigued to explore more.
mexican drugstore online: xxl mexican pharm – xxl mexican pharm
canadian pharmacy world coupon https://familypharmacy.company/# canadian pharmacy coupon code
pharmacy online 365 discount code https://familypharmacy.company/# Online pharmacy USA
Best online pharmacy online pharmacy delivery usa Online pharmacy USA
Best online pharmacy Best online pharmacy Cheapest online pharmacy