Skip to content

Commit

Permalink
add graphicsmagick
Browse files Browse the repository at this point in the history
  • Loading branch information
C4illin committed May 24, 2024
1 parent 3e2338a commit 4cf06d9
Show file tree
Hide file tree
Showing 9 changed files with 707 additions and 88 deletions.
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1-debian as base
WORKDIR /app

Expand Down Expand Up @@ -28,14 +26,20 @@ RUN cd /temp/prod && bun install --frozen-lockfile --production

# copy production dependencies and source code into final image
FROM base AS release
# install additional dependencies
RUN rm -rf /var/lib/apt/lists/partial && apt-get update -o Acquire::CompressionTypes::Order::=gz \
&& apt-get install -y \
pandoc \
texlive-latex-recommended \
ffmpeg \
graphicsmagick \
ghostscript

COPY --from=install /temp/prod/node_modules node_modules
# COPY --from=prerelease /app/src/index.tsx /app/src/
# COPY --from=prerelease /app/package.json .
COPY . .

# install additional dependencies
RUN apt-get update && apt-get install -y pandoc texlive-latex-recommended ffmpeg

# run the app
USER bun
EXPOSE 3000/tcp
Expand Down
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ConvertX

A self-hosted online file converter. Supports 708 different formats.
## Features

- Convert files to different formats
- Password protection
- Multiple accounts


## Converters supported

| Converter | Use case | Converts from | Converts to |
|----------------|---------------|---------------|-------------|
| Sharp | Images (fast) | 7 | 6 |
| Pandoc | Documents | 43 | 65 |
| GraphicsMagick | Images | 166 | 133 |
| FFmpeg | Video | 461 | 170 |

## Deployment

```yml
# docker-compose.yml
services:
convertx:
image: ghcr.io/c4illin/convertx:master
ports:
- "3000:3000"
environment: # Defaults are listed below
- ACCOUNT_REGISTRATION=false # true or false
volumes:
- /path/you/want:/app/data
```
<!-- or
```bash
docker run ghcr.io/c4illin/convertx:master -p 3000:3000 -e ACCOUNT_REGISTRATION=false -v /path/you/want:/app/data
``` -->
Then visit `http://localhost:3000` in your browser and create your account.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "convertx-frontend",
"version": "1.0.50",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "bun run --hot src/index.tsx"
"dev": "bun run --watch src/index.tsx",
"hot": "bun run --hot src/index.tsx"
},
"dependencies": {
"@elysiajs/cookie": "^0.8.0",
Expand Down
36 changes: 27 additions & 9 deletions src/converters/ffmpeg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,16 +659,34 @@ export async function convert(
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
options?: any,
) {
let command = "ffmpeg";

return exec(
`ffmpeg -f "${fileType}" -i "${filePath}" -f "${convertTo}" "${targetPath}"`,
(error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
const notWorking = ["bmp"];

if (!(fileType in notWorking)) {
command += ` -f "${fileType}"`;
}

command += ` -i "${filePath}"`;

if (!(convertTo in notWorking)) {
command += ` -f "${convertTo}"`;
}

command += " ${targetPath}";

return exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}

if (stdout) {
console.log(`stdout: ${stdout}`);
}

if (stderr) {
console.error(`stderr: ${stderr}`);
},
);
}
});
}
Loading

0 comments on commit 4cf06d9

Please sign in to comment.