1

I spend quite a bit of time asking questions and answering questions in allot of education/learning oriented communities. More recent forums use Markdown but there are still quite allot of forums that use BBCode as their markup interface, including my school.

To save myself some headache I use a markdown editing software (Obsidian) to write my questions/answers/replies. For those time where the destination is a BBCode forum , I want to use a shell script that takes a Markdown file as input and generates a BBCode version, saving the output to my clipboard.

The following snippet could be a markdown file, I include any media (Images or Gifs) I need, along with the dimensions:

One thing 1PP (1 Point Perspective) and 2PP (2 Point Perspective) will always have in common are the vertical lines, they are always true verticals:
![500x100](https://i.imgur.com/lTH5gg6.gif)
The above(1PP), the Y-axis of the box are paralell with the red, vertical lines. Its also the same for the below (2PP), the Y-axis of the box are paralell with the red, vertical lines
![500x100](https://i.imgur.com/ObMTgv0.gif)

The script will simply parse the Markdown file, returns an output like the following:

One thing 1PP (1 Point Perspective) and 2PP (2 Point Perspective) will always have in common are the vertical lines, they are always true verticals:
[imgwh=500,100]https://i.imgur.com/lTH5gg6.gif[/imgwh]    
The above(1PP), the Y-axis of the box are paralell with the red, vertical lines. Its also the same for the below (2PP), the Y-axis of the box are paralell with the red, vertical lines:
[imgwh=500,100]https://i.imgur.com/ObMTgv0.gif[/imgwh]   

I have written 90% of the shell script and works really well. I am stuck on finding a consistent means to resize images in BBCode. After some searching, I have learnt tags for resizing images are not a standard feature across forums that use BBCode, For example one forum supports resizing media with a tag like [imgwh] (the above example) while many others do not, you can only place an image.

Upon further search, I cam across THIS solution but its not ideal, I really need a means to be able to decide both the width and height, Also I wish to avoid abstracting dimensions to S, M, L etc.

I also experimented with FFMPEG/ImageMagick to resize media to the desired dimensions, before uploading them to a website. The results are horrendous and extremely slow, specially for gif files. I dont own a fast computer but I have a fast internet.

Is it possible to use HTML markup, to "force" BBCode to imbed images with specific dimensions? I don't know any HTML but if its possible I would learn it. If not then are there image hosting websites that you can request a size of the image in the URL itself, something like:

https://i.imgur.com/lTH5gg6_W500xH100.gif

Any help or just pointing me in the right direction, would be greatly appreciated!

2 Answers 2

2

You could use a resizing image proxy. These are websites that will resize an image on the fly for you, with caching.

There are quite a few of them, but (just to pick one) weserv is free, easy, fast and reliable.

https://images.weserv.nl

For example, wikipedia has this terrible 14,000 x 1,500 pixel image:

https://upload.wikimedia.org/wikipedia/commons/8/87/Chicago_Skyline_Hi-Res.jpg

You can ask for it to be resized to 500 pixels across like this:

https://images.weserv.nl/?url=upload.wikimedia.org/wikipedia/commons/8/87/Chicago_Skyline_Hi-Res.jpg&w=500

Try clicking the link. You can do a lot more than just resize images, check the docs.

https://images.weserv.nl/docs/quick-reference.html

  • It will serve most images with just a few milliseconds of delay
  • It uses cloudflare for world-wide caching and distribution
  • Very cheap to run, so it's free and will always be free
  • All the source code is on github
  • No data retention beyond a short caching period
  • Though having said that, if an image breaks something, they will investigate and might see your content
Sign up to request clarification or add additional context in comments.

Comments

1

Html can of course put the image any size you want, and it is worth a shot to try e.g. <img src="https://i.imgur.com/lTH5gg6.gif" width="500" height="100">.

However, I think most sites won't allow direct html in bbcode (don't quote me on this though, haven't used bb code much at all), and since you don't control the site you shouldn't be able to modify the actual html which eventually displays the image.

Did you check this out? They use both

[img=100x50]

and

[img width="100" height="50"]

to resize.

I think you might have to accept the fact that your script will need some kind of argument to modify the output depending on the BBCode version/implementation. Like my linked site says, BBCode isn't a rigorous standard. I don't think you'll find a method which works for all BBCode.

Then if you can't find an image hosting service like that (I couldn't with a quick google), you could always implement your own :)

1 Comment

Hehe you overestimate my competence, none the less thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.