carbon-now-cli icon indicating copy to clipboard operation
carbon-now-cli copied to clipboard

`widthAdjustment: true` do not exceed 1024px

Open am29d opened this issue 11 months ago • 4 comments

Describe the bug When I try to generate image with a long code line, the output image is fixed to 1024p for 1x and 2048p for 2x output size.

To Reproduce Steps to reproduce the behavior:

  1. Run carbon-now with…
  2. Wait for image to download…
  3. See error
  4. Paste code to carbon.now.sh using adjustWidth true
  5. The image is in full width without line breaks

** Code I am using **

import { BatchProcessor, EventType, processPartialResponse, } from '@aws-lambda-powertools/batch';
import type { SQSEvent, SQSRecord, Context, SQSBatchResponse } from 'aws-lambda';

const processor = new BatchProcessor(EventType.SQS);

const recordHandler = async (record: SQSRecord): Promise<void> => {
  const payload = record.body;
};

export const handler = async (
  event: SQSEvent,
  context: Context
): Promise<SQSBatchResponse> => {
  return processPartialResponse(event, recordHandler, processor, {context});
};

Configuration json file for the cli

{
    "latest-preset": {
        "theme": "night-owl",
        "backgroundColor": "#161E2D",
        "dropShadows": false,
        "exportSize": "1x",
        "firstLineNumber": 1,
        "fontFamily": "Hack",
        "fontSize": "18px",
        "language": "auto",
        "lineHeight": "133%",
        "lineNumbers": true,
        "selectedLines": "*",
        "squaredImage": false,
        "type": "png",
        "watermark": false,
        "widthAdjustment": true,
        "windowControls": false,
        "windowTheme": "none"
    }
}

Expected behavior I expect the tool to not break the line and take as much with as necessary

Screenshots Carbon website manually : Screenshot 2024-03-21 at 12 37 54

Output using cli batch-cmwtfGg40t

Carbon website using --open-in-browser flag:

Screenshot 2024-03-21 at 12 42 32

Edit: I tried to reduce the fontSize to 14 or 12, but the results are still ab bit weird, but the width seems to be correct:

batch-X2QN56ETIo

Info (please complete the following information):

  • OS [e.g. macOS, Linux, Windows, iOS]: macOS
  • --engine used [e.g. chromium, firefox, webkit]: all engines produce the same output
  • Carbon URL (run with --open-in-browser to see) [e.g. carbon.now.sh?bg=pink]: https://carbon.now.sh/?bg=%23161E2D&code=import%2520%257B%2520BatchProcessor%252C%2520EventType%252C%2520processPartialResponse%252C%2520%257D%2520from%2520%27%2540aws-lambda-powertools%252Fbatch%27%253B%250Aimport%2520type%2520%257B%2520SQSEvent%252C%2520SQSRecord%252C%2520Context%252C%2520SQSBatchResponse%2520%257D%2520from%2520%27aws-lambda%27%253B%250A%250Aconst%2520processor%2520%253D%2520new%2520BatchProcessor%28EventType.SQS%29%253B%250A%250Aconst%2520recordHandler%2520%253D%2520async%2520%28record%253A%2520SQSRecord%29%253A%2520Promise%253Cvoid%253E%2520%253D%253E%2520%257B%250A%2520%2520const%2520payload%2520%253D%2520record.body%253B%250A%257D%253B%250A%250Aexport%2520const%2520handler%2520%253D%2520async%2520%28%250A%2520%2520event%253A%2520SQSEvent%252C%250A%2520%2520context%253A%2520Context%250A%29%253A%2520Promise%253CSQSBatchResponse%253E%2520%253D%253E%2520%257B%250A%2520%2520return%2520processPartialResponse%28event%252C%2520recordHandler%252C%2520processor%252C%2520%257Bcontext%257D%29%253B%250A%257D%253B&dropShadows=false&ds=false&dsblur=68px&dsyoff=20px&es=1x&fl=1&fm=Hack&fs=18px&l=auto&lh=133%25&ln=true&ph=32px&pv=48px&si=false&sl=%2A&t=night-owl&type=png&wa=true&wc=false&wm=false&wt=none
Code snippet
  
  

am29d avatar Mar 21 '24 11:03 am29d

Hey @am29d, thanks for opening. Been quite swamped since the beginning of the year, but I will tackle a new release of the CLI soon and, amongst other things, address this (somehow.) 🙂 Thanks for your patience, appreciated!

mixn avatar May 31 '24 08:05 mixn

Bump... :) I have the same problem. It seems odd that it introduces unnecessary line breaks.

thomergil avatar Jun 25 '24 12:06 thomergil

Turns out, width is an undocumented option for carbon-now.json. I only discovered it because I exported the config from carbon.now.sh. You should add this to the documentation.

thomergil avatar Jun 25 '24 12:06 thomergil

Any update on this?

Tomas2D avatar Sep 13 '24 09:09 Tomas2D