Skip to content

Commit 89189fb

Browse files
authored
fix(conferia): better images, 1week token and attendees scroll (#368)
* fix(conferia): token of 1 week * fix(conferia): attendees scroll fix * fix(conferia): better images
1 parent ed9b97b commit 89189fb

File tree

5 files changed

+221
-32
lines changed

5 files changed

+221
-32
lines changed

packages/conferia/backend/src/main/java/icpmapp/services/impl/JWTServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public String generateToken(UserDetails userDetails){
2121
return Jwts.builder()
2222
.subject(userDetails.getUsername())
2323
.issuedAt(new Date(System.currentTimeMillis()))
24-
.expiration(new Date(System.currentTimeMillis() + 1000 * 60 * 30)) //milliseconds * seconds * minutes
24+
.expiration(new Date(System.currentTimeMillis() + 604800000)) // milliseconds (= 1 week)
2525
.signWith(getSigninKey())
2626
.compact();
2727
}

packages/conferia/backend/src/main/java/icpmapp/services/impl/StorageServiceImpl.java

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,31 @@ public byte[] convertToWebP(File inputImage) throws IOException {
249249
// Read the input image
250250
BufferedImage originalImage = ImageIO.read(inputImage);
251251

252-
// Calculate the new height to maintain the aspect ratio
253-
int targetWidth = 400;
252+
// Set higher quality limits - max width 1200px instead of 400px
253+
int maxWidth = 1200;
254254
int originalWidth = originalImage.getWidth();
255255
int originalHeight = originalImage.getHeight();
256-
int targetHeight = (targetWidth * originalHeight) / originalWidth;
257-
258-
// Resize the image
259-
Image resultingImage = originalImage.getScaledInstance(targetWidth, targetHeight, Image.SCALE_SMOOTH);
260-
BufferedImage outputImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB);
261-
Graphics2D g2d = outputImage.createGraphics();
262-
g2d.drawImage(resultingImage, 0, 0, null);
263-
g2d.dispose();
256+
257+
// Only resize if image is larger than max width
258+
BufferedImage outputImage;
259+
if (originalWidth > maxWidth) {
260+
int targetHeight = (maxWidth * originalHeight) / originalWidth;
261+
262+
// Use higher quality scaling with Graphics2D
263+
outputImage = new BufferedImage(maxWidth, targetHeight, BufferedImage.TYPE_INT_RGB);
264+
Graphics2D g2d = outputImage.createGraphics();
265+
266+
// Enable high-quality rendering
267+
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
268+
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
269+
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
270+
271+
g2d.drawImage(originalImage, 0, 0, maxWidth, targetHeight, null);
272+
g2d.dispose();
273+
} else {
274+
// Use original image if it's already small enough
275+
outputImage = originalImage;
276+
}
264277

265278
// Create a byte array output stream to capture the WebP output
266279
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {

packages/conferia/frontend/src/composables/usePhotoGallery.ts

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const usePhotoGallery = () => {
3333
};
3434

3535
/**
36-
* Process and compress image
36+
* Process and compress image with better quality settings
3737
*/
3838
const processImage = async (imageBlob: Blob, maxSize: number, maxHeight: number, maxWidth: number): Promise<Blob> => {
3939
return new Promise((resolve, reject) => {
@@ -55,18 +55,23 @@ export const usePhotoGallery = () => {
5555

5656
const ctx = canvas.getContext('2d');
5757
if (ctx) {
58+
// Enable high-quality image rendering
59+
ctx.imageSmoothingEnabled = true;
60+
ctx.imageSmoothingQuality = 'high';
5861
ctx.drawImage(img, 0, 0, width, height);
5962
}
60-
let quality = 1; // Start with 100% quality
61-
const step = 0.1; // Reduce quality by 10% each step
63+
64+
let quality = 1; // Start with 95% quality instead of 100%
65+
const step = 0.05; // Reduce quality by 5% each step (more gradual)
66+
const minQuality = 0.8; // Don't go below 80% quality (was 60%)
6267

6368
const reduceQualityParameter = () => {
6469
canvas.toBlob((blob) => {
6570
if (!blob) {
6671
reject(new Error('Failed to convert canvas to blob'));
6772
return;
6873
}
69-
if (blob.size <= convertedMaxSize || quality <= 0.6) {
74+
if (blob.size <= convertedMaxSize || quality <= minQuality) {
7075
resolve(blob);
7176
} else {
7277
quality -= step;
@@ -162,8 +167,8 @@ export const usePhotoGallery = () => {
162167
try {
163168
const stream = await navigator.mediaDevices.getUserMedia({
164169
video: {
165-
width: { ideal: 1280 },
166-
height: { ideal: 720 },
170+
width: { ideal: 1920, min: 1280 }, // Higher resolution for better quality
171+
height: { ideal: 1080, min: 720 },
167172
facingMode: 'user' // Front camera for profile photos
168173
}
169174
});
@@ -180,8 +185,15 @@ export const usePhotoGallery = () => {
180185
captureButton.onclick = () => {
181186
canvas.width = video.videoWidth;
182187
canvas.height = video.videoHeight;
183-
context?.drawImage(video, 0, 0);
184188

189+
// Use high-quality canvas rendering
190+
if (context) {
191+
context.imageSmoothingEnabled = true;
192+
context.imageSmoothingQuality = 'high';
193+
context.drawImage(video, 0, 0);
194+
}
195+
196+
// Increased JPEG quality from 0.9 to 0.95 for better camera captures
185197
canvas.toBlob((blob) => {
186198
if (blob) {
187199
stopCamera();
@@ -190,7 +202,7 @@ export const usePhotoGallery = () => {
190202
stopCamera();
191203
reject(new Error('Failed to capture photo'));
192204
}
193-
}, 'image/jpeg', 0.9);
205+
}, 'image/jpeg', 0.95);
194206
};
195207

196208
cancelButton.onclick = () => {
@@ -237,7 +249,7 @@ export const usePhotoGallery = () => {
237249
};
238250

239251
/**
240-
* Take photo for gallery (larger size)
252+
* Take photo for gallery (higher quality, less compression)
241253
*/
242254
const takePhotoGallery = async (): Promise<Blob> => {
243255
try {
@@ -249,14 +261,15 @@ export const usePhotoGallery = () => {
249261
photoBlob = await takePhotoWithFileInput();
250262
}
251263

252-
return await processImage(photoBlob, 1, 2000, 2000);
264+
// Increased size limit to 3MB and dimensions to 2400x2400 for better gallery quality
265+
return await processImage(photoBlob, 3, 2400, 2400);
253266
} catch (e) {
254267
throw new Error(`Failed to take photo: ${e instanceof Error ? e.message : 'Unknown error'}`);
255268
}
256269
};
257270

258271
/**
259-
* Take photo for profile (smaller, compressed)
272+
* Take photo for profile (smaller, but still good quality)
260273
*/
261274
const takePhotoProfile = async (): Promise<Blob> => {
262275
try {
@@ -268,7 +281,8 @@ export const usePhotoGallery = () => {
268281
photoBlob = await takePhotoWithFileInput();
269282
}
270283

271-
return await processImage(photoBlob, 0.2, 800, 600);
284+
// Increased size limit from 0.2MB to 1MB for better profile photo quality
285+
return await processImage(photoBlob, 1, 800, 600);
272286
} catch (e) {
273287
throw new Error(`Failed to take profile photo: ${e instanceof Error ? e.message : 'Unknown error'}`);
274288
}

packages/conferia/frontend/src/views/attendees/TabAttendeeDetail.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
size="small"
88
variant="outlined"
99
rounded
10-
@click="$router.back()" />
10+
@click="goBackToAttendees" />
1111
</template>
1212

1313
<div class="px-4 py-6 pb-20">
@@ -160,6 +160,20 @@ async function getImage(person: AttendeeDetail) {
160160
}
161161
}
162162
163+
/**
164+
* Navigate back to attendees list, preserving scroll position
165+
*/
166+
function goBackToAttendees(): void {
167+
// Use router.back() for better browser navigation experience
168+
// The attendees page will handle scroll restoration automatically
169+
if (window.history.length > 1) {
170+
router.back();
171+
} else {
172+
// Fallback if no history
173+
void router.push('/tabs/attendees');
174+
}
175+
}
176+
163177
/**
164178
* Navigate to personalized agenda
165179
*/

0 commit comments

Comments
 (0)