Skip to content

Commit

Permalink
画質荒くする
Browse files Browse the repository at this point in the history
  • Loading branch information
Kubosaka committed Nov 14, 2024
1 parent 0036ac2 commit 792f7dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions app/src/app/camera/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Toaster } from "@/components/ui/sonner";
import type { ScoreResponse, User, todayAssignment } from "@/types";
import imageCompression from "browser-image-compression";
import type React from "react";
import { useEffect, useRef, useState } from "react";
import { Camera, type CameraType } from "react-camera-pro";
Expand Down Expand Up @@ -163,10 +164,24 @@ const CameraApp = () => {
setIsUploading(true);
try {
const base64Response = await fetch(imageData);
const blob = await base64Response.blob();
const originalBlob = await base64Response.blob();

const compressOptions = {
maxSizeMB: 0.01,
maxWidthOrHeight: 1920,
useWebWorker: true,
};

const originalFile = new File([originalBlob], "tempImage", {
type: originalBlob.type,
});

const compressedBlob = await imageCompression(
originalFile,
compressOptions,
);

// 拡張子取得
const compressedBlob = blob; // Assuming no compression is needed
const Extension = compressedBlob.type.split("/")[1];

// 日付取得
Expand Down

0 comments on commit 792f7dc

Please sign in to comment.