可以使用HTML标记来“强制”BBCode嵌入具有特定尺寸的图片吗?

huangapple go评论55阅读模式
英文:

Is it possible to use HTML markup, to "force" BBCode to imbed images with specific dimensions?

问题

以下是您要翻译的内容:

"I spend quite a bit of time asking questions and answering questions in a lot of education/learning-oriented communities. More recent forums use Markdown but there are still quite a lot 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 times 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:
可以使用HTML标记来“强制”BBCode嵌入具有特定尺寸的图片吗?
The above(1PP), the Y-axis of the box is parallel with the red, vertical lines. It's also the same for the below (2PP), the Y-axis of the box is parallel with the red, vertical lines.
可以使用HTML标记来“强制”BBCode嵌入具有特定尺寸的图片吗?

The script will simply parse the Markdown file, return 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 is parallel with the red, vertical lines. It's also the same for the below (2PP), the Y-axis of the box is parallel with the red, vertical lines:
[imgwh=500,100]https://i.imgur.com/ObMTgv0.gif[/imgwh]

I have written 90% of the shell script and it works really well. I am stuck on finding a consistent means to resize images in BBCode. After some searching, I have learned 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 came across THIS solution but it's 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, especially for gif files. I don't own a fast computer but I have fast internet.

Is it possible to use HTML markup to "force" BBCode to embed images with specific dimensions? I don't know any HTML, but if it's possible, I would learn it. If not, 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!"

英文:

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!

答案1

得分: 1

以下是翻译好的部分:

HTML当然可以将图像放置在任何你想要的尺寸,值得尝试,例如<img src="https://i.imgur.com/lTH5gg6.gif" width="500" height="100">

但是,我认为大多数网站不允许直接在bbcode中使用HTML(不过不要引用我的话,我几乎没有使用bbcode),而且由于你无法控制网站,因此无法修改最终显示图像的实际HTML。

你是否查看了这个?它们使用了以下两种方式来调整大小:



我认为你可能需要接受这样一个事实,即你的脚本可能需要一些参数来根据BBCode的版本/实现来修改输出。就像我链接的网站所说,BBCode并不是一个严格的标准。我不认为你会找到适用于所有BBCode的方法。

如果你找不到类似的图像托管服务(我在快速搜索中也找不到),你可以考虑自己实现一个 可以使用HTML标记来“强制”BBCode嵌入具有特定尺寸的图片吗?

英文:

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


and


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 可以使用HTML标记来“强制”BBCode嵌入具有特定尺寸的图片吗?

答案2

得分: 1

你可以使用一个图片大小调整的代理服务。这些网站可以为你实时调整图片大小,并且带有缓存功能。

有很多免费的选择,比如 weserv 很简单易用,而且非常快速可靠。

https://images.weserv.nl

例如,维基百科有这张糟糕的 14,000 x 1,500 像素的图片:

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

你可以请求将其调整为 500 像素宽,像这样:

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

试试点击链接。你不仅可以调整图片大小,还可以查看文档了解更多功能。

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

  • 它会在几毫秒内为大多数图片提供服务
  • 它使用 cloudflare 进行全球缓存和分发
  • 运行成本非常低,所以它是免费的,永远都会免费
  • 所有源代码都在 github 上
  • 在短暂的缓存期限之后不会保留任何数据
  • 尽管如此,如果一张图片导致了问题,他们会进行调查,可能会查看到你的内容。
英文:

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 free ones, but for example weserv is really easy, and very 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

huangapple
  • 本文由 发表于 2023年4月11日 10:19:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75981967.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定