You've already forked collage-maker
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
4578e64597 | |||
a97d98c3e6 | |||
c7e5fb83fc | |||
b432769d6f | |||
b4d58817a5 |
@ -11,7 +11,6 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
|
|
||||||
"github.com/disintegration/imaging"
|
"github.com/disintegration/imaging"
|
||||||
"go.oneofone.dev/resize"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Dimension struct {
|
type Dimension struct {
|
||||||
@ -65,13 +64,13 @@ func Make(req *Request, source fs.FS, output io.Writer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destRect := FrameTranslate(req.Aspect, req.Dimension, photo.Frame).ToImgRect()
|
destRect := FrameTranslate(req.Aspect, req.Dimension, photo.Frame).ToImgRect()
|
||||||
resizedImg := resize.Resize(uint(destRect.Dx()), uint(destRect.Dy()), croppedImage, resize.Lanczos3)
|
resizedImg := imaging.Resize(croppedImage, destRect.Dx(), destRect.Dy(), imaging.Lanczos)
|
||||||
draw.Draw(canvas, destRect, resizedImg, image.Point{0, 0}, draw.Src)
|
draw.Draw(canvas, destRect, resizedImg, image.Point{0, 0}, draw.Src)
|
||||||
}
|
}
|
||||||
var opt jpeg.Options
|
|
||||||
opt.Quality = 100
|
|
||||||
|
|
||||||
return jpeg.Encode(output, canvas, &opt)
|
return jpeg.Encode(output, canvas, &jpeg.Options{
|
||||||
|
Quality: 100,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func FrameTranslate(resolution Dimension, frameSize Dimension, frame Rectangle) Rectangle {
|
func FrameTranslate(resolution Dimension, frameSize Dimension, frame Rectangle) Rectangle {
|
||||||
|
1
go.mod
1
go.mod
@ -5,7 +5,6 @@ go 1.22
|
|||||||
require (
|
require (
|
||||||
github.com/disintegration/imaging v1.6.2
|
github.com/disintegration/imaging v1.6.2
|
||||||
go.balki.me/anyhttp v0.3.0
|
go.balki.me/anyhttp v0.3.0
|
||||||
go.oneofone.dev/resize v1.0.1
|
|
||||||
)
|
)
|
||||||
|
|
||||||
require golang.org/x/image v0.1.0 // indirect
|
require golang.org/x/image v0.1.0 // indirect
|
||||||
|
2
go.sum
2
go.sum
@ -3,8 +3,6 @@ github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44am
|
|||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
go.balki.me/anyhttp v0.3.0 h1:WtBQ0rnkg567sX/O4ij/+qBbdCIUt5VURSe718sITBY=
|
go.balki.me/anyhttp v0.3.0 h1:WtBQ0rnkg567sX/O4ij/+qBbdCIUt5VURSe718sITBY=
|
||||||
go.balki.me/anyhttp v0.3.0/go.mod h1:JhfekOIjgVODoVqUCficjpIgmB3wwlB7jhN0eN2EZ/s=
|
go.balki.me/anyhttp v0.3.0/go.mod h1:JhfekOIjgVODoVqUCficjpIgmB3wwlB7jhN0eN2EZ/s=
|
||||||
go.oneofone.dev/resize v1.0.1 h1:HjpVar/4pxMGrjO44ThaMX1Q5UOBw0KxzbxxRDZPQuA=
|
|
||||||
go.oneofone.dev/resize v1.0.1/go.mod h1:zGFmn7q4EUZVlnDmxqf+b0mWpxsTt0MH2yx6ng8tpq0=
|
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
|
@ -43,7 +43,7 @@ function main() {
|
|||||||
loadPhotosBtn.onclick = () => loadPhotos()
|
loadPhotosBtn.onclick = () => loadPhotos()
|
||||||
makeCollageBtn.onclick = () => gotoCollage()
|
makeCollageBtn.onclick = () => gotoCollage()
|
||||||
|
|
||||||
/** @type HTMLImageElement[] */
|
/** @type HTMLCollectionOf<HTMLImageElement> */
|
||||||
const selectedPhotos = selectedPhotosDiv.getElementsByTagName("img")
|
const selectedPhotos = selectedPhotosDiv.getElementsByTagName("img")
|
||||||
for (const img of selectedPhotos) {
|
for (const img of selectedPhotos) {
|
||||||
img.onclick = () => {
|
img.onclick = () => {
|
||||||
@ -55,6 +55,17 @@ function main() {
|
|||||||
selectedPhotos[0].click()
|
selectedPhotos[0].click()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function moveToNextSlot() {
|
||||||
|
/** @type HTMLCollectionOf<HTMLImageElement> */
|
||||||
|
const selectedPhotos = selectedPhotosDiv.getElementsByTagName("img")
|
||||||
|
for (const img of selectedPhotos) {
|
||||||
|
if(img.src.endsWith("stock.svg")) {
|
||||||
|
img.click()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function loadAlbums() {
|
function loadAlbums() {
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
@ -110,11 +121,12 @@ function loadPhotos() {
|
|||||||
albumPhotosDiv.appendChild(img)
|
albumPhotosDiv.appendChild(img)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type HTMLImageElement[] */
|
/** @type HTMLCollectionOf<HTMLImageElement> */
|
||||||
const photoImgs = albumPhotosDiv.children
|
const photoImgs = albumPhotosDiv.children
|
||||||
for(const photo of photoImgs) {
|
for(const photo of photoImgs) {
|
||||||
photo.onclick = () => {
|
photo.onclick = () => {
|
||||||
selectedPhotoImg.src = photo.src
|
selectedPhotoImg.src = photo.src
|
||||||
|
moveToNextSlot()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@ -124,7 +136,7 @@ function loadPhotos() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function gotoCollage() {
|
function gotoCollage() {
|
||||||
/** @type HTMLImageElement[] */
|
/** @type HTMLCollectionOf<HTMLImageElement> */
|
||||||
const selectedPhotos = selectedPhotosDiv.getElementsByTagName("img")
|
const selectedPhotos = selectedPhotosDiv.getElementsByTagName("img")
|
||||||
/** @type String[] */
|
/** @type String[] */
|
||||||
const photoUrls = [];
|
const photoUrls = [];
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex: 25%;
|
flex: 25%;
|
||||||
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
.imagebox {
|
.imagebox {
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
@ -44,8 +45,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.template {
|
.template {
|
||||||
width: 100px;
|
width: 6rem;
|
||||||
height: 100px;
|
height: 6rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.template-selected {
|
.template-selected {
|
||||||
@ -87,10 +88,10 @@
|
|||||||
.two-one-two-topbottom {
|
.two-one-two-topbottom {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"A B"
|
"A B"
|
||||||
"C C"
|
"C C"
|
||||||
"C C"
|
"C C"
|
||||||
"D E"
|
"D E";
|
||||||
}
|
}
|
||||||
|
|
||||||
.two-one-two-topbottom .img1 {
|
.two-one-two-topbottom .img1 {
|
||||||
@ -100,17 +101,27 @@
|
|||||||
.two-row {
|
.two-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"A B"
|
"A B";
|
||||||
}
|
}
|
||||||
|
|
||||||
.three-row {
|
.three-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"A B C"
|
"A B C";
|
||||||
}
|
}
|
||||||
|
|
||||||
.four-row {
|
.four-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"A B C D"
|
"A B C D";
|
||||||
|
}
|
||||||
|
|
||||||
|
.one-three-topbottom {
|
||||||
|
display: grid;
|
||||||
|
grid-template-areas:
|
||||||
|
"A A A"
|
||||||
|
"B C D";
|
||||||
|
}
|
||||||
|
.one-three-topbottom .img1 {
|
||||||
|
grid-area: A;
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,12 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
|
||||||
<p><a href="choose.html">Select Images</a></p>
|
<h2>Photo Collage</h2>
|
||||||
|
<p><a href="choose.html">Select Images</a></p>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<span>Paper size</span>
|
<span>Paper size</span>
|
||||||
<select id="page_size_selector" size=6>
|
<select id="page_size_selector">
|
||||||
<option value="letter-portrait" > Letter (Portrait) </option>
|
<option value="letter-portrait" > Letter (Portrait) </option>
|
||||||
<option selected value="letter-landscape" > Letter (Landscape) </option>
|
<option selected value="letter-landscape" > Letter (Landscape) </option>
|
||||||
<option value="fiveseven-portrait" > 5 × 7 (Portrait) </option>
|
<option value="fiveseven-portrait" > 5 × 7 (Portrait) </option>
|
||||||
@ -26,6 +27,12 @@
|
|||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<button id="snapper" class="showbuton">Snap Collage</button>
|
||||||
|
<div>
|
||||||
|
<p><a href="/collages/" target="_blank" >All collages</a></p>
|
||||||
|
<p><a href="" target="_blank" id="collage-url"></a></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<ul class="templates">
|
<ul class="templates">
|
||||||
<li>
|
<li>
|
||||||
@ -113,10 +120,35 @@
|
|||||||
<div class="img img12"></div>
|
<div class="img img12"></div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<div class="template three-row">
|
||||||
|
<div class="img img1"></div>
|
||||||
|
<div class="img img2"></div>
|
||||||
|
<div class="img img3"></div>
|
||||||
|
<div class="img img4"></div>
|
||||||
|
<div class="img img5"></div>
|
||||||
|
<div class="img img6"></div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<div class="template two-row">
|
||||||
|
<div class="img img1"></div>
|
||||||
|
<div class="img img2"></div>
|
||||||
|
<div class="img img3"></div>
|
||||||
|
<div class="img img4"></div>
|
||||||
|
<div class="img img5"></div>
|
||||||
|
<div class="img img6"></div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<div class="template one-three-topbottom">
|
||||||
|
<div class="img img1"></div>
|
||||||
|
<div class="img img2"></div>
|
||||||
|
<div class="img img3"></div>
|
||||||
|
<div class="img img4"></div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<button id="snapper" class="showbuton">Snap Collage</button>
|
|
||||||
<p><a href="" target="_blank" id="collage-url"></a></p>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="imagebox">
|
<div class="imagebox">
|
||||||
|
Reference in New Issue
Block a user