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"
|
||||
|
||||
"github.com/disintegration/imaging"
|
||||
"go.oneofone.dev/resize"
|
||||
)
|
||||
|
||||
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()
|
||||
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)
|
||||
}
|
||||
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 {
|
||||
|
1
go.mod
1
go.mod
@ -5,7 +5,6 @@ go 1.22
|
||||
require (
|
||||
github.com/disintegration/imaging v1.6.2
|
||||
go.balki.me/anyhttp v0.3.0
|
||||
go.oneofone.dev/resize v1.0.1
|
||||
)
|
||||
|
||||
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=
|
||||
go.balki.me/anyhttp v0.3.0 h1:WtBQ0rnkg567sX/O4ij/+qBbdCIUt5VURSe718sITBY=
|
||||
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-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
|
@ -43,7 +43,7 @@ function main() {
|
||||
loadPhotosBtn.onclick = () => loadPhotos()
|
||||
makeCollageBtn.onclick = () => gotoCollage()
|
||||
|
||||
/** @type HTMLImageElement[] */
|
||||
/** @type HTMLCollectionOf<HTMLImageElement> */
|
||||
const selectedPhotos = selectedPhotosDiv.getElementsByTagName("img")
|
||||
for (const img of selectedPhotos) {
|
||||
img.onclick = () => {
|
||||
@ -55,6 +55,17 @@ function main() {
|
||||
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() {
|
||||
(async () => {
|
||||
try {
|
||||
@ -110,11 +121,12 @@ function loadPhotos() {
|
||||
albumPhotosDiv.appendChild(img)
|
||||
}
|
||||
|
||||
/** @type HTMLImageElement[] */
|
||||
/** @type HTMLCollectionOf<HTMLImageElement> */
|
||||
const photoImgs = albumPhotosDiv.children
|
||||
for(const photo of photoImgs) {
|
||||
photo.onclick = () => {
|
||||
selectedPhotoImg.src = photo.src
|
||||
moveToNextSlot()
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
@ -124,7 +136,7 @@ function loadPhotos() {
|
||||
}
|
||||
|
||||
function gotoCollage() {
|
||||
/** @type HTMLImageElement[] */
|
||||
/** @type HTMLCollectionOf<HTMLImageElement> */
|
||||
const selectedPhotos = selectedPhotosDiv.getElementsByTagName("img")
|
||||
/** @type String[] */
|
||||
const photoUrls = [];
|
||||
|
@ -10,6 +10,7 @@
|
||||
justify-content: space-around;
|
||||
flex-direction: column;
|
||||
flex: 25%;
|
||||
overflow: scroll;
|
||||
}
|
||||
.imagebox {
|
||||
padding: 2rem;
|
||||
@ -44,8 +45,8 @@
|
||||
}
|
||||
|
||||
.template {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
width: 6rem;
|
||||
height: 6rem;
|
||||
}
|
||||
|
||||
.template-selected {
|
||||
@ -90,7 +91,7 @@
|
||||
"A B"
|
||||
"C C"
|
||||
"C C"
|
||||
"D E"
|
||||
"D E";
|
||||
}
|
||||
|
||||
.two-one-two-topbottom .img1 {
|
||||
@ -100,17 +101,27 @@
|
||||
.two-row {
|
||||
display: grid;
|
||||
grid-template-areas:
|
||||
"A B"
|
||||
"A B";
|
||||
}
|
||||
|
||||
.three-row {
|
||||
display: grid;
|
||||
grid-template-areas:
|
||||
"A B C"
|
||||
"A B C";
|
||||
}
|
||||
|
||||
.four-row {
|
||||
display: grid;
|
||||
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="controls">
|
||||
|
||||
<h2>Photo Collage</h2>
|
||||
<p><a href="choose.html">Select Images</a></p>
|
||||
|
||||
<label>
|
||||
<span>Paper size</span>
|
||||
<select id="page_size_selector" size=6>
|
||||
<select id="page_size_selector">
|
||||
<option value="letter-portrait" > Letter (Portrait) </option>
|
||||
<option selected value="letter-landscape" > Letter (Landscape) </option>
|
||||
<option value="fiveseven-portrait" > 5 × 7 (Portrait) </option>
|
||||
@ -26,6 +27,12 @@
|
||||
</select>
|
||||
</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">
|
||||
<li>
|
||||
@ -113,10 +120,35 @@
|
||||
<div class="img img12"></div>
|
||||
</div>
|
||||
</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>
|
||||
<button id="snapper" class="showbuton">Snap Collage</button>
|
||||
<p><a href="" target="_blank" id="collage-url"></a></p>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="imagebox">
|
||||
|
Reference in New Issue
Block a user