Skip to content

Commit

Permalink
preview overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Jun 25, 2024
1 parent 1940fb4 commit 0e23a2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
17 changes: 6 additions & 11 deletions api/schema_screenshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,12 @@ func (api Api) GetFirstSchemaScreenshot(w http.ResponseWriter, r *http.Request)
return
}

ratio := float64(img.Bounds().Max.X) / float64(img.Bounds().Max.Y)
newRatio := float64(width) / float64(height)

// TODO: fix this mess properly
if ratio < newRatio {
// source image is taller
width = int(float64(width) * ratio)
} else {
// source image is wider
height = int(float64(height) / ratio)
}
oldWidth := img.Bounds().Max.X
oldHeight := img.Bounds().Max.Y
ratio := min(float64(width)/float64(oldWidth), float64(height)/float64(oldHeight))
height = int(float64(oldHeight) * ratio)
width = int(float64(oldWidth) * ratio)
fmt.Printf("oldWidth: %d, oldHeight: %d, ratio: %.2f\n", oldWidth, oldHeight, ratio)

newImage := resize.Resize(uint(width), uint(height), img, resize.Bilinear)

Expand Down
3 changes: 1 addition & 2 deletions public/js/components/SchemaList.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ export default {
<router-link :to="schema_link(entry)">
<img
:src="preview_src(entry.schema)"
class="card-img-top"
style="background-color: #3c3737; min-height: 200px;"/>
style="background-color: #3c3737; min-height: 200px; display: block; margin-left: auto; margin-right: auto;"/>
</router-link>
<div class="card-body">
<h5 class="card-title">
Expand Down

0 comments on commit 0e23a2e

Please sign in to comment.