Skip to content

Commit

Permalink
Fix gr.Image height inconsistencies (#8852)
Browse files Browse the repository at this point in the history
* * prevent source selection cut off
* add height:100% to image-container
* ensure elements are centered

* add changeset

* add changeset

* change cover to contain

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
  • Loading branch information
3 people authored Jul 22, 2024
1 parent a238af4 commit 16b8200
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 10 deletions.
9 changes: 9 additions & 0 deletions .changeset/yellow-cooks-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@gradio/atoms": patch
"@gradio/image": patch
"@gradio/imageeditor": patch
"@gradio/simpleimage": patch
"gradio": patch
---

fix:Fix gr.Image height inconsistencies
6 changes: 2 additions & 4 deletions js/atoms/src/SelectSource.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,10 @@
align-items: center;
justify-content: center;
border-top: 1px solid var(--border-color-primary);
width: 95%;
bottom: 0;
left: 0;
right: 0;
width: 100%;
margin-left: auto;
margin-right: auto;
height: var(--size-10);
}
.icon {
Expand Down
3 changes: 3 additions & 0 deletions js/image/shared/ImagePreview.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
{/if}

<style>
.image-container {
height: 100%;
}
.image-container :global(img),
button {
width: var(--size-full);
Expand Down
8 changes: 6 additions & 2 deletions js/image/shared/ImageUploader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
}}
/>
{/if}
<div class="upload-container">
<div class="upload-container" class:reduced-height={sources.length > 1}>
<Upload
hidden={value !== null || active_source === "webcam"}
bind:this={upload_input}
Expand Down Expand Up @@ -165,7 +165,7 @@
.image-frame :global(img) {
width: var(--size-full);
height: var(--size-full);
object-fit: cover;
object-fit: contain;
}
.image-frame {
Expand All @@ -181,6 +181,10 @@
width: 100%;
}
.reduced-height {
height: calc(100% - var(--size-10));
}
.image-container {
display: flex;
height: 100%;
Expand Down
6 changes: 5 additions & 1 deletion js/image/shared/Webcam.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,11 @@
class:hide={!webcam_accessed}
/>
{#if !webcam_accessed}
<div in:fade={{ delay: 100, duration: 200 }} title="grant webcam access">
<div
in:fade={{ delay: 100, duration: 200 }}
title="grant webcam access"
style="height: 100%"
>
<WebcamPermissions on:click={async () => access_webcam()} />
</div>
{:else}
Expand Down
1 change: 0 additions & 1 deletion js/imageeditor/shared/tools/Sources.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@
width: 100%;
left: 0;
top: 0;
/* background-color: pink; */
}
.upload-container.click-disabled {
Expand Down
3 changes: 3 additions & 0 deletions js/simpleimage/shared/ImagePreview.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
{/if}

<style>
.image-container {
height: 100%;
}
.image-container :global(img),
button {
width: var(--size-full);
Expand Down
3 changes: 1 addition & 2 deletions js/simpleimage/shared/ImageUploader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@
.image-frame :global(img) {
width: var(--size-full);
height: var(--size-full);
object-fit: cover;
object-fit: contain;
}
.image-frame {
object-fit: cover;
width: 100%;
height: 100%;
}
Expand Down

0 comments on commit 16b8200

Please sign in to comment.