Requested WMS image width exceeds the server maximum - openlayers-3

A customer has a wms layer in mapserver that's configured with a 2048 maximum width and height.
When OL3 issues the getmap request, it may ask for an image width that exceeds the maximum and the resulting image is more narrow than what was requested. The resulting map layer is offset.
Map offset example
Is there a workaround or bugfix?
We're using version 3.10.1 of Openlayers

You could increase the maximum size in your MapServer configuration or use ol.source.TileWMS to load the image data as tiles.

For later versions of OpenLayers (final release of OL3 onwards) if you don't have access to the server and using TileWMS would cause problems with label duplication there is a workaround. First keep image requests as small as possible by setting hidpi: false and ratio: 1 in the ImageWMS source constructor. Also be aware that using view rotation will increase the width or height by up to sqrt(2) times normal. However in some cases, such as preparing a 300 dpi A3 print, map canvas widths greater than 4096 px are inevitable. To preserve detail from other layers you wouldn't want to reduce the dpi. Instead you can use a custom image load function to scale down the WMS image request to a maximum value and then stretch the output back to what OpenLayers was expecting. This demo restricts the WMS request width and height to 4096 when a 300 dpi A3 PDF requires a 4962 px (more if rotated) wide image https://codepen.io/anon/pen/bPvExb

Related

from big png-file image less in width/height with maximum quality

I need to make from big png-file image less in width/height with maximum quality, despite of its size
I use imagemagick command like:
/usr/bin/convert -sample 1201x847 -density 600 "source_file.png" -quality 100 "dest_file.png"
I get png file but I would like to get image of better quality...
I set width/height of output file as -sample 1201x847
That is clear with -quality 100 - best quality
Not clear with density parameter
I read a doc:
-density width
-density widthxheight
Set the horizontal and vertical resolution of an image for rendering to devices.
This option specifies the image resolution to store while encoding a raster image or the canvas resolution while rendering (reading) vector formats such as Postscript, PDF, WMF, and SVG into a raster image. Image resolution provides the unit of measure to apply when rendering to an output device or raster image. The default unit of measure is in dots per inch (DPI). The -units option may be used to select dots per centimeter instead.
The default resolution is 72 dots per inch, which is equivalent to one point per pixel (Macintosh and Postscript standard). Computer screens are normally 72 or 96 dots per inch, while printers typically support 150, 300, 600, or 1200 dots per inch. To determine the resolution of your display, use a ruler to measure the width of your screen in inches, and divide by the number of horizontal pixels (1024 on a 1024x768 display).
If the file format supports it, this option may be used to update the stored image resolution. Note that Photoshop stores and obtains image resolution from a proprietary embedded profile. If this profile is not stripped from the image, then Photoshop will continue to treat the image using its former resolution, ignoring the image resolution specified in the standard file header.
The -density option sets an attribute and does not alter the underlying raster image. It may be used to adjust the rendered size for desktop publishing purposes by adjusting the scale applied to the pixels. To resize the image so that it is the same size at a different resolution, use the -resample option.
Did they mean params of monitor of client screen.width and screen.height ?
As it was written:
use a ruler to measure the width of your screen in inches, and divide by the number of horizontal pixels (1024 on a 1024x768 display
It was not actually very clear about these parameters and how to calc it.
Also googling I see using of parameters -sharpen, -trim, -resample - do they influence quality of resulting and if yes how to use them ?
About source png file I know only that it is result of fabrics js canvas using html2canvas function.
How to get image of better quality?
Thanks!

Is there a maximum image width in iOS (image I have is 25020 x 238)? Image works when resized

This image (http://imgur.com/TyPtrxy) will not load in the simulator, although when I scale it to half the size it loads just fine. When trying to load the full image I just get a black box where it should be.
Yes, there is a maximum image size (number of pixels). The limit depends on the hardware in part, but it is generally in the range of 5 to 10 million pixels. This limit is related to limitations on the maximum sizes of textures that can be sent to the graphics card; therefore, it only applies to images that are drawn.
From the documentation:
You should avoid creating UIImage objects that are greater than 1024 x 1024 in size. Besides the large amount of memory such an image would consume, you may run into problems when using the image as a texture in OpenGL ES or when drawing the image to a view or layer. This size restriction does not apply if you are performing code-based manipulations, such as resizing an image larger than 1024 x 1024 pixels by drawing it to a bitmap-backed graphics context. In fact, you may need to resize an image in this manner (or break it into several smaller images) in order to draw it to one of your views.
It might be that you are hitting some limits on the maximum size of the CALayer (which in turn is dependent on the maximum OpenGL texture size supported by the hardware) that is backing the view. If you're exceeding the maximum size, a message like CoreAnimation: surface <size> is too large will be logged. It's also possible that the decompressed image may be too large to fit in memory. You should use CATiledLayer to display content of that size to ensure that it stays within the resource constraints of the device.
Just to expand a bit on the other answers.
The UIImage documentation (as of iOS 10) no longer seems to mention size limitations, although if you use UIImageView with images whose dimensions are larger than the maximum texture size* supported by the device you happen to be using you do get very large memory consumption at render time.
(The memory consumption I see in Instruments seems to indicate that the entire image is put into a 32 bits per pixel buffer when the CA::Layer is rendered.)
If your app doesn't get kill by the OS due to memory usage, the UIImageView does still end up displaying the image though.
Given this, you'll still need strategies to deal with very large images.
* You can check the maximum texture size using something like glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);. Just make sure you've set the EAGLContext current context to be something non-nil before querying OpenGL, otherwise you'll get zero.

controlling the resolution (dpi) of an exported JPG from highcharts exporting-server

I have read the recent posts on the Highcharts.com website regarding their updated PhantomJS based exporting-server. I have also cloned their github repository and successfully compiled their web-service. However, all files produced by this server are marked as 96dpi, which is inadequate for my purposes. According to somewhat contradictory information on the Highcharts.com website (Here and Here), they are using Batik to rasterize PNG and JPG output, which should make it possible to adjust the DPI settings of the exported raster images. However, the pom.xml doesn't include any batik references and I can't find anything in the source code which indicates that anything other than PhantomJS is being used to produce the raster renditions. The PhantomJS export might be able to adjust the DPI, but I can only find the scale and width options which don't directly adjust the DPI, thus requiring a tedious post-processing rescale (or metadata edit) to adjust the DPI accordingly.
So, the meat of my question: how to adjust the exported DPI of a highcharts chart in PNG and JPG format when using the highcharts java exporting-server?
The release before the last one used both Batik and PhantomJS. The last release uses only PhantomJS. This is why you do not find any Batik references in the pom.xml anymore.
For controlling the dpi of the exported image. You should use the scale parameter. For completeness sake, here is how Highcharts determines the dpi of the exported image.
Controling the size of the exported image
Since Highcharts 3.0 and Highstock 1.3, the size of the exported image is computed based on a few rules:
If the exporting.sourceWidth and exporting.sourceHeight options are set, they take predence. This provides a convenient way of having separate sizes of the on-screen chart and the exported one.
If not, and the chart.width and chart.height options are set, those are used for the exported chart.
If a size hasn't been found yet, and the containing div has an explicit pixel width or height, that width or height is used. Percentage and other non-pixel widths will not take effect. This prevents a common pitfall in Highcharts 2, where charts with the typical 100% width would look out of proportion in export.
If a size still hasn't been found, it defaults to 600 by 400 pixels.
After rendering the chart width the above size, and all text sizes in relation to that, the actual image resolution is determined by exporting.scale which defaults to 2. In practice this means that a 600x400 chart will return an image of 1200x800 pixels by default. The rationale behind this is quite simple - if we used a scale of 1 and just set the sourceWidth to 1200 and sourceHeight to 800, all the text would become too small. And if we didn't scale it up, the resolution would be too small for print.
Read also here for more on the export server

TImageviewer maximum size

Does anyone know what is the maximum width and height of a Bitmap in a FireMonkey TImageViewer?
I am drawing vector graphics in a TImageViewer. I am only able to zoom up to a certain value then I get a memory exceprion.
I've tested this on two seperate computers and it would appear that the actual size limit to a Bitmap in Firemonkey is 8000x8000 px meaning both Width and Height respectively cap at 8000 px size.
This is what I observed, if anyone gets a different result please let me know.
How you plan to get around that is up to you, I would suggest dissecting the source image into multiple parts so that neither part excedes the limit and then assign each part to a different Bitmap component(such as TImageViewer) and then make it all come together as a whole.

How can I scale an image with ColdFusion without losing resolution?

Server Config:
Windows Server 2003
IIS 6
ColdFusion 8 Standard Edition
Java Version 6 Update 18
I have a ColdFusion application that allows users to upload images that will be added to an existing PDF. When the images are added to the PDF, they have to fit within a minimum/maximum height and width, so the uploaded image needs to be scaled to fit.
For instance, let's say the minimum height and width for a given image is 100x100, and the maximum height and width is 200x200, and the user uploads an image that is 500x1000. I use the logic below to scale that image down without skewing the image (it keeps its original shape) to 100x200. For an image smaller than the minimum, it is scaled up (in the example above, a 50x50 image would be scaled up to 100x100).
The problem I'm noticing is that when ColdFusion scales the image using its built-in functions, it reduces the resolution to 72dpi. Is there a way to prevent this loss of resolution, as the images are being added to PDFs which need to be print-quality?
Here's the [scaled-down] code I'm using to scale the images:
<cfscript>
imagePath = "/uploads/image.tif";
scaledWidth = 100;
scaledHeight = 100;
scaledImage = ImageNew(imagePath);
ImageSetAntialiasing(scaledImage, "on");
ImageScaleToFit(scaledImage, scaledWidth, scaledHeight);
</cfscript>
I think you may want to skip scaling the image at all and add the original image to the pdf document. Then have whatever pdf creation tool you are using "resize" and position the image on the document canvas. Similar to setting width and height on images in html to something other than its native resolution. I have not had to add images to PDFs docs like you described but this post might point you in the right direction:
Adding a dynamic image to a PDF using ColdFusion and iText

Resources